1. 17 Jun, 2021 40 commits
    • Jacopo Mondi's avatar
      media: i2c: max9271: Check max9271_write() return · ad01032a
      Jacopo Mondi authored
      Check the return value of the max9271_write() function in the
      max9271 library driver.
      
      While at it, modify an existing condition to be made identical
      to other checks.
      Signed-off-by: default avatarJacopo Mondi <jacopo+renesas@jmondi.org>
      Reviewed-by: default avatarKieran Bingham <kieran.bingham+renesas@ideasonboard.com>
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      ad01032a
    • Jacopo Mondi's avatar
      media: i2c: max9286: Rework comments in .bound() · 4ff5278d
      Jacopo Mondi authored
      Rephrase a comment in .bound() callback to make it clear we register
      a subdev notifier and remove a redundant comment about disabling i2c
      auto-ack.
      
      No functional changes intended.
      Signed-off-by: default avatarJacopo Mondi <jacopo+renesas@jmondi.org>
      Reviewed-by: default avatarKieran Bingham <kieran.bingham+renesas@ideasonboard.com>
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      4ff5278d
    • Jacopo Mondi's avatar
      media: i2c: max9286: Define high channel amplitude · 731c24ff
      Jacopo Mondi authored
      Provide a macro to define the reverse channel amplitude to
      be used to compensate the remote serializer noise immunity.
      
      While at it, update a comment.
      Signed-off-by: default avatarJacopo Mondi <jacopo+renesas@jmondi.org>
      Reviewed-by: default avatarKieran Bingham <kieran.bingham+renesas@ideasonboard.com>
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      731c24ff
    • Jacopo Mondi's avatar
      media: i2c: max9286: Cache channel amplitude · 902edc2a
      Jacopo Mondi authored
      Cache the current channel amplitude in a driver variable
      to skip updating it if the newly requested value is the same
      as the currently configured one.
      Signed-off-by: default avatarJacopo Mondi <jacopo+renesas@jmondi.org>
      Reviewed-by: default avatarKieran Bingham <kieran.bingham+renesas@ideasonboard.com>
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      902edc2a
    • Jacopo Mondi's avatar
      media: i2c: max9286: Rename reverse_channel_mv · f78723eb
      Jacopo Mondi authored
      Rename the reverse_channel_mv variable to init_rev_chan_mv as
      the next patch will cache the reverse channel amplitude in
      a new driver variable.
      Signed-off-by: default avatarJacopo Mondi <jacopo+renesas@jmondi.org>
      Reviewed-by: default avatarKieran Bingham <kieran.bingham+renesas@ideasonboard.com>
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      f78723eb
    • Jacopo Mondi's avatar
      media: i2c: max9286: Adjust parameters indent · 3de09c7a
      Jacopo Mondi authored
      The parameters to max9286_i2c_mux_configure() fits on the previous
      line. Adjust it.
      
      Cosmetic change only.
      Signed-off-by: default avatarJacopo Mondi <jacopo+renesas@jmondi.org>
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Reviewed-by: default avatarKieran Bingham <kieran.bingham+renesas@ideasonboard.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      3de09c7a
    • Alex Bee's avatar
      media: hantro: add support for Rockchip RK3036 · 4f345915
      Alex Bee authored
      RK3036's VPU IP block is the same as RK3288 has, except that it doesn't
      have an encoder, decoding is supported up to 1920x1088 only and the axi
      clock can be set to 300 MHz max.
      
      Add a new RK3036 variant which reflects these differences.
      Signed-off-by: default avatarAlex Bee <knaerzche@gmail.com>
      Reviewed-by: default avatarEzequiel Garcia <ezequiel@collabora.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      4f345915
    • Alex Bee's avatar
      media: hantro: add support for Rockchip RK3066 · 78bb1ae5
      Alex Bee authored
      RK3066's VPU IP block is the predecessor from what RK3288 has.
      The hardware differences are:
        - supports decoding frame sizes up to 1920x1088 only
        - doesn't have the 'G1_REG_SOFT_RESET' register
          (requires another .reset callback for hantro_codec_ops,
           since writing this register will result in non-working
           IP block)
        - has one ACLK/HCLK per vdpu/vepu
        - ACLKs can be clocked up to 300 MHz only
        - no MMU
          (no changes required: CMA will be transparently used)
      
      Add a new RK3066 variant which reflect this differences. This variant
      can be used for RK3188 as well.
      Signed-off-by: default avatarAlex Bee <knaerzche@gmail.com>
      Reviewed-by: default avatarEzequiel Garcia <ezequiel@collabora.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      78bb1ae5
    • Alex Bee's avatar
      media: hantro: merge Rockchip platform drivers · c9caebd5
      Alex Bee authored
      Merge the two Rockchip platform drivers into one as it was suggested at
      [1] and [2].
      This will hopefully make it easier to add new variants (which are surely
      to come for Rockchip).
      Also rename from "rk3288" to "v(d/e)pu1" and "rk3399" to "v(d/e)pu2"
      where applicable, as this is the dicition the vendor uses and will
      also refelect the variants that get added later in this series. Rename
      from "rk3288" to "rockchip" if applicable to both hardware versions.
      
      [1] https://patchwork.kernel.org/project/linux-rockchip/patch/20210107134101.195426-6-paul.kocialkowski@bootlin.com/
      [2] https://patchwork.kernel.org/project/linux-rockchip/patch/20210525152225.154302-5-knaerzche@gmail.com/Signed-off-by: default avatarAlex Bee <knaerzche@gmail.com>
      Reviewed-by: default avatarEzequiel Garcia <ezequiel@collabora.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      c9caebd5
    • Alex Bee's avatar
      media: hantro: reorder variants · 4b898fed
      Alex Bee authored
      Reorder variants in hantro driver alphanumeric.
      Signed-off-by: default avatarAlex Bee <knaerzche@gmail.com>
      Reviewed-by: default avatarEzequiel Garcia <ezequiel@collabora.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      4b898fed
    • Alex Bee's avatar
      media: dt-bindings: media: rockchip-vdec: add RK3228 compatible · 502cf736
      Alex Bee authored
      Document the RK3228 compatible for rockchip-vdec.
      Also add the optional assigned-clocks and assigned-clock-rates
      properties.
      Signed-off-by: default avatarAlex Bee <knaerzche@gmail.com>
      Reviewed-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      502cf736
    • Alex Bee's avatar
      media: dt-bindings: media: rockchip-vpu: add new compatibles · b32178e7
      Alex Bee authored
      Add compatibles for RK3036, RK3066, RK3188 and RK3228. Also reflect the
      changes to the additional clocks for RK3066/RK3188.
      Signed-off-by: default avatarAlex Bee <knaerzche@gmail.com>
      Reviewed-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      b32178e7
    • Hans Verkuil's avatar
      media: mtk-vcodec: fix kerneldoc warnings · 493ae3f2
      Hans Verkuil authored
      Fix the following kerneldoc warnings:
      
      drivers/media/platform/mtk-vcodec/venc_ipi_msg.h:31: warning: Enum value 'AP_IPIMSG_ENC_INIT' not described in enum 'venc_ipi_msg_id'
      drivers/media/platform/mtk-vcodec/venc_ipi_msg.h:31: warning: Enum value 'AP_IPIMSG_ENC_SET_PARAM' not described in enum 'venc_ipi_msg_id'
      drivers/media/platform/mtk-vcodec/venc_ipi_msg.h:31: warning: Enum value 'AP_IPIMSG_ENC_ENCODE' not described in enum 'venc_ipi_msg_id'
      drivers/media/platform/mtk-vcodec/venc_ipi_msg.h:31: warning: Enum value 'AP_IPIMSG_ENC_DEINIT' not described in enum 'venc_ipi_msg_id'
      drivers/media/platform/mtk-vcodec/venc_ipi_msg.h:31: warning: Enum value 'VPU_IPIMSG_ENC_INIT_DONE' not described in enum 'venc_ipi_msg_id'
      drivers/media/platform/mtk-vcodec/venc_ipi_msg.h:31: warning: Enum value 'VPU_IPIMSG_ENC_SET_PARAM_DONE' not described in enum 'venc_ipi_msg_id'
      drivers/media/platform/mtk-vcodec/venc_ipi_msg.h:31: warning: Enum value 'VPU_IPIMSG_ENC_ENCODE_DONE' not described in enum 'venc_ipi_msg_id'
      drivers/media/platform/mtk-vcodec/venc_ipi_msg.h:31: warning: Enum value 'VPU_IPIMSG_ENC_DEINIT_DONE' not described in enum 'venc_ipi_msg_id'
      drivers/media/platform/mtk-vcodec/venc_ipi_msg.h:31: warning: Excess enum value 'VPU_IPIMSG_ENC_XXX_DONE' description in 'venc_ipi_msg_id'
      drivers/media/platform/mtk-vcodec/venc_ipi_msg.h:31: warning: Excess enum value 'AP_IPIMSG_ENC_XXX' description in 'venc_ipi_msg_id'
      drivers/media/platform/mtk-vcodec/venc_ipi_msg.h:120: warning: Enum value 'VENC_IPI_MSG_STATUS_OK' not described in enum 'venc_ipi_msg_status'
      drivers/media/platform/mtk-vcodec/venc_ipi_msg.h:120: warning: Enum value 'VENC_IPI_MSG_STATUS_FAIL' not described in enum 'venc_ipi_msg_status'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:50: warning: Enum value 'VDEC_SYS' not described in enum 'mtk_hw_reg_idx'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:50: warning: Enum value 'VDEC_MISC' not described in enum 'mtk_hw_reg_idx'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:50: warning: Enum value 'VDEC_LD' not described in enum 'mtk_hw_reg_idx'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:50: warning: Enum value 'VDEC_TOP' not described in enum 'mtk_hw_reg_idx'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:50: warning: Enum value 'VDEC_CM' not described in enum 'mtk_hw_reg_idx'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:50: warning: Enum value 'VDEC_AD' not described in enum 'mtk_hw_reg_idx'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:50: warning: Enum value 'VDEC_AV' not described in enum 'mtk_hw_reg_idx'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:50: warning: Enum value 'VDEC_PP' not described in enum 'mtk_hw_reg_idx'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:50: warning: Enum value 'VDEC_HWD' not described in enum 'mtk_hw_reg_idx'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:50: warning: Enum value 'VDEC_HWQ' not described in enum 'mtk_hw_reg_idx'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:50: warning: Enum value 'VDEC_HWB' not described in enum 'mtk_hw_reg_idx'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:50: warning: Enum value 'VDEC_HWG' not described in enum 'mtk_hw_reg_idx'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:50: warning: Enum value 'NUM_MAX_VDEC_REG_BASE' not described in enum 'mtk_hw_reg_idx'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:50: warning: Enum value 'VENC_SYS' not described in enum 'mtk_hw_reg_idx'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:50: warning: Enum value 'VENC_LT_SYS' not described in enum 'mtk_hw_reg_idx'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:50: warning: Enum value 'NUM_MAX_VCODEC_REG_BASE' not described in enum 'mtk_hw_reg_idx'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:58: warning: Enum value 'MTK_INST_DECODER' not described in enum 'mtk_instance_type'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:58: warning: Enum value 'MTK_INST_ENCODER' not described in enum 'mtk_instance_type'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:87: warning: Enum value 'MTK_ENCODE_PARAM_NONE' not described in enum 'mtk_encode_param'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:87: warning: Enum value 'MTK_ENCODE_PARAM_BITRATE' not described in enum 'mtk_encode_param'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:87: warning: Enum value 'MTK_ENCODE_PARAM_FRAMERATE' not described in enum 'mtk_encode_param'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:87: warning: Enum value 'MTK_ENCODE_PARAM_INTRA_PERIOD' not described in enum
      'mtk_encode_param'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:87: warning: Enum value 'MTK_ENCODE_PARAM_FORCE_INTRA' not described in enum
      'mtk_encode_param'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:87: warning: Enum value 'MTK_ENCODE_PARAM_GOP_SIZE' not described in enum 'mtk_encode_param'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:103: warning: Function parameter or member 'fourcc' not described in 'mtk_video_fmt'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:103: warning: Function parameter or member 'type' not described in 'mtk_video_fmt'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:103: warning: Function parameter or member 'num_planes' not described in 'mtk_video_fmt'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:103: warning: Function parameter or member 'flags' not described in 'mtk_video_fmt'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:112: warning: Function parameter or member 'fourcc' not described in 'mtk_codec_framesizes'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:112: warning: Function parameter or member 'stepwise' not described in 'mtk_codec_framesizes'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:120: warning: Enum value 'MTK_Q_DATA_SRC' not described in enum 'mtk_q_type'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:120: warning: Enum value 'MTK_Q_DATA_DST' not described in enum 'mtk_q_type'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:134: warning: Function parameter or member 'visible_width' not described in 'mtk_q_data'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:134: warning: Function parameter or member 'visible_height' not described in 'mtk_q_data'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:134: warning: Function parameter or member 'coded_width' not described in 'mtk_q_data'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:134: warning: Function parameter or member 'coded_height' not described in 'mtk_q_data'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:134: warning: Function parameter or member 'field' not described in 'mtk_q_data'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:134: warning: Function parameter or member 'bytesperline' not described in 'mtk_q_data'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:134: warning: Function parameter or member 'sizeimage' not described in 'mtk_q_data'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:134: warning: Function parameter or member 'fmt' not described in 'mtk_q_data'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:177: warning: Function parameter or member 'clk_name' not described in 'mtk_vcodec_clk_info'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:177: warning: Function parameter or member 'vcodec_clk' not described in
      'mtk_vcodec_clk_info'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:185: warning: Function parameter or member 'clk_info' not described in 'mtk_vcodec_clk'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:185: warning: Function parameter or member 'clk_num' not described in 'mtk_vcodec_clk'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:198: warning: Function parameter or member 'vdec_clk' not described in 'mtk_vcodec_pm'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:198: warning: Function parameter or member 'larbvdec' not described in 'mtk_vcodec_pm'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:198: warning: Function parameter or member 'venc_clk' not described in 'mtk_vcodec_pm'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:198: warning: Function parameter or member 'larbvenc' not described in 'mtk_vcodec_pm'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:198: warning: Function parameter or member 'dev' not described in 'mtk_vcodec_pm'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:198: warning: Function parameter or member 'mtkdev' not described in 'mtk_vcodec_pm'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:300: warning: Function parameter or member 'decoded_frame_cnt' not described in
      'mtk_vcodec_ctx'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:332: warning: Function parameter or member 'min_bitrate' not described in
      'mtk_vcodec_enc_pdata'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:405: warning: Function parameter or member 'venc_pdata' not described in 'mtk_vcodec_dev'
      drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h:405: warning: Function parameter or member 'decode_workqueue' not described in
      'mtk_vcodec_dev'
      drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h:27: warning: Enum value 'AP_IPIMSG_DEC_INIT' not described in enum 'vdec_ipi_msgid'
      drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h:27: warning: Enum value 'AP_IPIMSG_DEC_START' not described in enum 'vdec_ipi_msgid'
      drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h:27: warning: Enum value 'AP_IPIMSG_DEC_END' not described in enum 'vdec_ipi_msgid'
      drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h:27: warning: Enum value 'AP_IPIMSG_DEC_DEINIT' not described in enum 'vdec_ipi_msgid'
      drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h:27: warning: Enum value 'AP_IPIMSG_DEC_RESET' not described in enum 'vdec_ipi_msgid'
      drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h:27: warning: Enum value 'VPU_IPIMSG_DEC_INIT_ACK' not described in enum 'vdec_ipi_msgid'
      drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h:27: warning: Enum value 'VPU_IPIMSG_DEC_START_ACK' not described in enum 'vdec_ipi_msgid'
      drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h:27: warning: Enum value 'VPU_IPIMSG_DEC_END_ACK' not described in enum 'vdec_ipi_msgid'
      drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h:27: warning: Enum value 'VPU_IPIMSG_DEC_DEINIT_ACK' not described in enum 'vdec_ipi_msgid'
      drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h:27: warning: Enum value 'VPU_IPIMSG_DEC_RESET_ACK' not described in enum 'vdec_ipi_msgid'
      drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h:27: warning: Excess enum value 'AP_IPIMSG_XXX' description in 'vdec_ipi_msgid'
      drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h:27: warning: Excess enum value 'VPU_IPIMSG_XXX_ACK' description in 'vdec_ipi_msgid'
      
      In some cases I just changed /** to /*, in other cases the missing
      field descriptions were added.
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      493ae3f2
    • Hans Verkuil's avatar
      media: adv7842: remove spurious & and fix vga_edid size · 7629cbd6
      Hans Verkuil authored
      No need to use & to get the start address of an array.
      
      Fix the size of vga_edid.edid to a single block (128 bytes) to fix
      this smatch error:
      
      adv7842.c:2538 adv7842_set_edid() error: memcpy() '&state->vga_edid.edid' too small (128 vs 512)
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      7629cbd6
    • Christophe JAILLET's avatar
      media: pci: cx88: switch from 'pci_' to 'dma_' API · 00ae4ebc
      Christophe JAILLET authored
      The wrappers in include/linux/pci-dma-compat.h should go away.
      
      The patch has been generated with the coccinelle script below and has been
      hand modified to replace GFP_ with a correct flag.
      It has been compile tested.
      
      Only 2 functions allocate some memory. They are both in cx88-core.c
      
      When memory is allocated in 'cx88_risc_buffer()', GFP_KERNEL can be
      used because its 2 callers end up to '.buf_prepare' functions in 'vb2_ops'
      structures.
      The call chains are:
      
        .buf_prepare                   (cx88-vbi.c)
          --> buffer_prepare           (cx88-vbi.c)
            --> cx88_risc_buffer
      
        .buf_prepare                   (cx88-video.c)
          --> buffer_prepare           (cx88-video.c)
            --> cx88_risc_buffer
      
      When memory is allocated in 'cx88_risc_databuffer()', GFP_KERNEL can be
      used because its 2 callers end up to 'snd_cx88_hw_params' which already
      uses GFP_KERNEL and '.buf_prepare' functions in 'vb2_ops' structures.
      The call chains are:
      
        snd_cx88_hw_params                   (cx88-alsa.c)
          --> cx88_risc_databuffer
      
        .buf_prepare                         (cx88-blackbird.c)
          --> buffer_prepare                 (cx88-blackbird.c)
            --> cx8802_buf_prepare           (cx88-mpeg.c)
              --> cx88_risc_databuffer
      
        .buf_prepare                         (cx88-dvb.c)
          --> buffer_prepare                 (cx88-dvb.c)
            --> cx8802_buf_prepare           (cx88-mpeg.c)
              --> cx88_risc_databuffer
      
      @@ @@
      -    PCI_DMA_BIDIRECTIONAL
      +    DMA_BIDIRECTIONAL
      
      @@ @@
      -    PCI_DMA_TODEVICE
      +    DMA_TO_DEVICE
      
      @@ @@
      -    PCI_DMA_FROMDEVICE
      +    DMA_FROM_DEVICE
      
      @@ @@
      -    PCI_DMA_NONE
      +    DMA_NONE
      
      @@
      expression e1, e2, e3;
      @@
      -    pci_alloc_consistent(e1, e2, e3)
      +    dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
      
      @@
      expression e1, e2, e3;
      @@
      -    pci_zalloc_consistent(e1, e2, e3)
      +    dma_alloc_coherent(&e1->dev, e2, e3, GFP_)
      
      @@
      expression e1, e2, e3, e4;
      @@
      -    pci_free_consistent(e1, e2, e3, e4)
      +    dma_free_coherent(&e1->dev, e2, e3, e4)
      
      @@
      expression e1, e2, e3, e4;
      @@
      -    pci_map_single(e1, e2, e3, e4)
      +    dma_map_single(&e1->dev, e2, e3, e4)
      
      @@
      expression e1, e2, e3, e4;
      @@
      -    pci_unmap_single(e1, e2, e3, e4)
      +    dma_unmap_single(&e1->dev, e2, e3, e4)
      
      @@
      expression e1, e2, e3, e4, e5;
      @@
      -    pci_map_page(e1, e2, e3, e4, e5)
      +    dma_map_page(&e1->dev, e2, e3, e4, e5)
      
      @@
      expression e1, e2, e3, e4;
      @@
      -    pci_unmap_page(e1, e2, e3, e4)
      +    dma_unmap_page(&e1->dev, e2, e3, e4)
      
      @@
      expression e1, e2, e3, e4;
      @@
      -    pci_map_sg(e1, e2, e3, e4)
      +    dma_map_sg(&e1->dev, e2, e3, e4)
      
      @@
      expression e1, e2, e3, e4;
      @@
      -    pci_unmap_sg(e1, e2, e3, e4)
      +    dma_unmap_sg(&e1->dev, e2, e3, e4)
      
      @@
      expression e1, e2, e3, e4;
      @@
      -    pci_dma_sync_single_for_cpu(e1, e2, e3, e4)
      +    dma_sync_single_for_cpu(&e1->dev, e2, e3, e4)
      
      @@
      expression e1, e2, e3, e4;
      @@
      -    pci_dma_sync_single_for_device(e1, e2, e3, e4)
      +    dma_sync_single_for_device(&e1->dev, e2, e3, e4)
      
      @@
      expression e1, e2, e3, e4;
      @@
      -    pci_dma_sync_sg_for_cpu(e1, e2, e3, e4)
      +    dma_sync_sg_for_cpu(&e1->dev, e2, e3, e4)
      
      @@
      expression e1, e2, e3, e4;
      @@
      -    pci_dma_sync_sg_for_device(e1, e2, e3, e4)
      +    dma_sync_sg_for_device(&e1->dev, e2, e3, e4)
      
      @@
      expression e1, e2;
      @@
      -    pci_dma_mapping_error(e1, e2)
      +    dma_mapping_error(&e1->dev, e2)
      
      @@
      expression e1, e2;
      @@
      -    pci_set_dma_mask(e1, e2)
      +    dma_set_mask(&e1->dev, e2)
      
      @@
      expression e1, e2;
      @@
      -    pci_set_consistent_dma_mask(e1, e2)
      +    dma_set_coherent_mask(&e1->dev, e2)
      Signed-off-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      00ae4ebc
    • Rikard Falkeborn's avatar
      media: imx-jpeg: Constify static struct mxc_jpeg_fmt · 7ec1c4a5
      Rikard Falkeborn authored
      It is only read-from, so make it const. In order to be able to do this,
      constify all places where mxc_jpeg_fmt is used, in function arguments,
      return values and pointers. On top of that, make the name a pointer to
      const char.
      
      On aarch64, this shrinks object code size with 550 bytes with gcc 11.1.0,
      and almost 2kB with clang 12.0.0.
      Signed-off-by: default avatarRikard Falkeborn <rikard.falkeborn@gmail.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      7ec1c4a5
    • Rikard Falkeborn's avatar
      media: imx-jpeg: Constify static struct v4l2_m2m_ops · 682e69d7
      Rikard Falkeborn authored
      The only usage of mxc_jpeg_m2m_ops is to pass its address to
      v4l2_m2m_init() which takes a pointer to const struct v4l2_m2m_ops. Make
      it const to allow the compiler to put it in read-only memory.
      Signed-off-by: default avatarRikard Falkeborn <rikard.falkeborn@gmail.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      682e69d7
    • Niklas Söderlund's avatar
      media: rcar-csi2: Add support for Y10 and Y8 · e70bc1ea
      Niklas Söderlund authored
      Add support for two new media bus formats, Y10 and Y8.
      Signed-off-by: default avatarNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      e70bc1ea
    • lijian's avatar
      media: v4l2-event: Modified variable type 'unsigned' to 'unsigned int' · 40d62da2
      lijian authored
      Prefer 'unsigned int' to bare use of 'unsigned'.
      So modified variable type 'unsigned' to 'unsigned int' in v4l2-event.c.
      Signed-off-by: default avatarlijian <lijian@yulong.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      40d62da2
    • Piyush Thange's avatar
      media: usb: cpia2: Fixed Coding Style issues · 584b2373
      Piyush Thange authored
      Fixed all the Coding style issues generated by checkpatch.pl.
      The changes made considering the --strict option.
      Signed-off-by: default avatarPiyush Thange <pthange19@gmail.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      584b2373
    • Dillon Min's avatar
      media: s5p-g2d: Fix a memory leak on ctx->fh.m2m_ctx · 5d11e6aa
      Dillon Min authored
      The m2m_ctx resources was allocated by v4l2_m2m_ctx_init() in g2d_open()
      should be freed from g2d_release() when it's not used.
      
      Fix it
      
      Fixes: 91884734 ("[media] v4l: add G2D driver for s5p device family")
      Signed-off-by: default avatarDillon Min <dillon.minfei@gmail.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      5d11e6aa
    • Evgeny Novikov's avatar
      media: marvell-ccic: set error code in probe · 2b889a4a
      Evgeny Novikov authored
      When i2c_new_client_device() fails, cafe_pci_probe() cleans up all
      resources and returns 0. The patch sets the error code on the
      corresponding path.
      
      Found by Linux Driver Verification project (linuxtesting.org).
      Signed-off-by: default avatarEvgeny Novikov <novikov@ispras.ru>
      Acked-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      2b889a4a
    • Steve Longerbeam's avatar
      media: imx-csi: Skip first few frames from a BT.656 source · e198be37
      Steve Longerbeam authored
      Some BT.656 sensors (e.g. ADV718x) transmit frames with unstable BT.656
      sync codes after initial power on. This confuses the imx CSI,resulting
      in vertical and/or horizontal sync issues. Skip the first 20 frames
      to avoid the unstable sync codes.
      
      [fabio: fixed checkpatch warning and increased the frame skipping to 20]
      Signed-off-by: default avatarSteve Longerbeam <slongerbeam@gmail.com>
      Signed-off-by: default avatarFabio Estevam <festevam@gmail.com>
      Reviewed-by: default avatarTim Harvey <tharvey@gateworks.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      e198be37
    • Wolfram Sang's avatar
      media: coda: set debugfs blobs to read only · ca816468
      Wolfram Sang authored
      Those blobs can only be read. So, don't confuse users with 'writable'
      flags.
      Signed-off-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      ca816468
    • Arnd Bergmann's avatar
      media: subdev: disallow ioctl for saa6588/davinci · 0a7790be
      Arnd Bergmann authored
      The saa6588_ioctl() function expects to get called from other kernel
      functions with a 'saa6588_command' pointer, but I found nothing stops it
      from getting called from user space instead, which seems rather dangerous.
      
      The same thing happens in the davinci vpbe driver with its VENC_GET_FLD
      command.
      
      As a quick fix, add a separate .command() callback pointer for this
      driver and change the two callers over to that.  This change can easily
      get backported to stable kernels if necessary, but since there are only
      two drivers, we may want to eventually replace this with a set of more
      specialized callbacks in the long run.
      
      Fixes: c3fda7f8 ("V4L/DVB (10537): saa6588: convert to v4l2_subdev.")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      0a7790be
    • Arnd Bergmann's avatar
      media: atomisp: remove compat_ioctl32 code · b4c650f1
      Arnd Bergmann authored
      This is one of the last remaining users of compat_alloc_user_space()
      and copy_in_user(), which are in the process of getting removed.
      
      As of commit 57e6b6f2 ("media: atomisp_fops.c: disable
      atomisp_compat_ioctl32"), nothing in this file is actually getting used
      as the only reference has been stubbed out.
      
      Remove the entire file -- anyone willing to restore the functionality
      can equally well just look up the contents in the git history if needed.
      Acked-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Suggested-by: default avatarChristoph Hellwig <hch@lst.de>
      Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Acked-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      b4c650f1
    • Arnd Bergmann's avatar
      media: v4l2-core: return -ENODEV from ioctl when not registered · 8162f78d
      Arnd Bergmann authored
      I spotted a minor difference is handling of unregistered devices
      between native and compat ioctls: the native handler never tries
      to call into the driver if a device is not marked as registered.
      
      I did not check whether this can cause issues in the kernel, or
      just a different between return codes, but it clearly makes
      sense that both should behave the same way.
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      8162f78d
    • Arnd Bergmann's avatar
      media: subdev: remove VIDIOC_DQEVENT_TIME32 handling · 765ba251
      Arnd Bergmann authored
      Converting the VIDIOC_DQEVENT_TIME32/VIDIOC_DQEVENT32/
      VIDIOC_DQEVENT32_TIME32 arguments to the canonical form is done in common
      code, but for some reason I ended up adding another conversion helper to
      subdev_do_ioctl() as well. I must have concluded that this does not go
      through the common conversion, but it has done that since the ioctl
      handler was first added.
      
      I assume this one is harmless as there should be no way to arrive here
      from user space if CONFIG_COMPAT_32BIT_TIME is set, but since it is dead
      code, it should just get removed.
      
      On a 64-bit architecture, as well as a 32-bit architecture without
      CONFIG_COMPAT_32BIT_TIME, handling this command is a mistake,
      and the kernel should return an error.
      
      Fixes: 1a6c0b36 ("media: v4l2-core: fix VIDIOC_DQEVENT for time64 ABI")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      765ba251
    • Arnd Bergmann's avatar
      media: v4l2-core: fix whitespace damage in video_get_user() · e84c8932
      Arnd Bergmann authored
      The initialization was indented with an extra tab in most lines,
      remove them to get the normal coding style.
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      e84c8932
    • Arnd Bergmann's avatar
      media: v4l2-core: explicitly clear ioctl input data · 7b53cca7
      Arnd Bergmann authored
      As seen from a recent syzbot bug report, mistakes in the compat ioctl
      implementation can lead to uninitialized kernel stack data getting used
      as input for driver ioctl handlers.
      
      The reported bug is now fixed, but it's possible that other related
      bugs are still present or get added in the future. As the drivers need
      to check user input already, the possible impact is fairly low, but it
      might still cause an information leak.
      
      To be on the safe side, always clear the entire ioctl buffer before
      calling the conversion handler functions that are meant to initialize
      them.
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      7b53cca7
    • Arnd Bergmann's avatar
      media: v4l2-core: ignore native time32 ioctls on 64-bit · c344f07a
      Arnd Bergmann authored
      Syzbot found that passing ioctl command 0xc0505609 into a 64-bit
      kernel from a 32-bit process causes uninitialized kernel memory to
      get passed to drivers instead of the user space data:
      
      BUG: KMSAN: uninit-value in check_array_args drivers/media/v4l2-core/v4l2-ioctl.c:3041 [inline]
      BUG: KMSAN: uninit-value in video_usercopy+0x1631/0x3d30 drivers/media/v4l2-core/v4l2-ioctl.c:3315
      CPU: 0 PID: 19595 Comm: syz-executor.4 Not tainted 5.11.0-rc7-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
      Call Trace:
       __dump_stack lib/dump_stack.c:79 [inline]
       dump_stack+0x21c/0x280 lib/dump_stack.c:120
       kmsan_report+0xfb/0x1e0 mm/kmsan/kmsan_report.c:118
       __msan_warning+0x5f/0xa0 mm/kmsan/kmsan_instr.c:197
       check_array_args drivers/media/v4l2-core/v4l2-ioctl.c:3041 [inline]
       video_usercopy+0x1631/0x3d30 drivers/media/v4l2-core/v4l2-ioctl.c:3315
       video_ioctl2+0x9f/0xb0 drivers/media/v4l2-core/v4l2-ioctl.c:3391
       v4l2_ioctl+0x255/0x290 drivers/media/v4l2-core/v4l2-dev.c:360
       v4l2_compat_ioctl32+0x2c6/0x370 drivers/media/v4l2-core/v4l2-compat-ioctl32.c:1248
       __do_compat_sys_ioctl fs/ioctl.c:842 [inline]
       __se_compat_sys_ioctl+0x53d/0x1100 fs/ioctl.c:793
       __ia32_compat_sys_ioctl+0x4a/0x70 fs/ioctl.c:793
       do_syscall_32_irqs_on arch/x86/entry/common.c:79 [inline]
       __do_fast_syscall_32+0x102/0x160 arch/x86/entry/common.c:141
       do_fast_syscall_32+0x6a/0xc0 arch/x86/entry/common.c:166
       do_SYSENTER_32+0x73/0x90 arch/x86/entry/common.c:209
       entry_SYSENTER_compat_after_hwframe+0x4d/0x5c
      
      The time32 commands are defined but were never meant to be called on
      64-bit machines, as those have always used time64 interfaces.  I missed
      this in my patch that introduced the time64 handling on 32-bit platforms.
      
      The problem in this case is the mismatch of one function checking for
      the numeric value of the command and another function checking for the
      type of process (native vs compat) instead, with the result being that
      for this combination, nothing gets copied into the buffer at all.
      
      Avoid this by only trying to convert the time32 commands when running
      on a 32-bit kernel where these are defined in a meaningful way.
      
      [hverkuil: fix 3 warnings: switch with no cases]
      
      Fixes: 577c89b0 ("media: v4l2-core: fix v4l2_buffer handling for time64 ABI")
      Reported-by: syzbot+142888ffec98ab194028@syzkaller.appspotmail.com
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      c344f07a
    • Irui Wang's avatar
      media: mtk-vcodec: Support MT8192 H264 4K encoding · caf231ac
      Irui Wang authored
      MT8192 H264 support 4k(3840x2176) and Level 5.1 encoding,
      add related path according to enc_capability.
      Signed-off-by: default avatarIrui Wang <irui.wang@mediatek.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      caf231ac
    • Irui Wang's avatar
      media: mtk-vcodec: Add MT8192 H264 venc driver · 37eeacba
      Irui Wang authored
      Add MT8192 venc driver's compatible and device private data.
      Reviewed-by: default avatarTzung-Bi Shih <tzungbi@google.com>
      Signed-off-by: default avatarIrui Wang <irui.wang@mediatek.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      37eeacba
    • Irui Wang's avatar
      media: dt-bindings: media: mtk-vcodec: Add binding for MT8192 VENC · aa950d86
      Irui Wang authored
      Updates binding document for mt8192 encoder driver.
      Acked-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarIrui Wang <irui.wang@mediatek.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      aa950d86
    • Irui Wang's avatar
      media: mtk-vcodec: Support 34bits dma address for venc · c2c3bde0
      Irui Wang authored
      Use the dma_set_mask_and_coherent helper to set venc
      DMA bit mask to support 34bits iova space(16GB) that
      the mt8192 iommu HW support.
      
      Whole the iova range separate to 0~4G/4G~8G/8G~12G/12G~16G,
      regarding which iova range VENC actually locate, it
      depends on the dma-ranges property of venc dtsi node.
      Signed-off-by: default avatarIrui Wang <irui.wang@mediatek.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      c2c3bde0
    • Irui Wang's avatar
      media: dt-bindings: media: mtk-vcodec: Add dma-ranges property · 5cd57605
      Irui Wang authored
      The mt8192 iommu support 0~16GB iova. We separate it to four banks:
      0~4G; 4G~8G; 8G~12G; 12G~16G.
      
      The "dma-ranges" could be used to adjust the bank we locate.
      If we don't set this property. The default range always is 0~4G.
      
      This is optional and only needed in mt8192, the dma ranges should
      not cross 4G/8G/12G.
      
      Here we don't have actual bus/parent concept here.  And the iova
      requirement is for our HW. Thus put the property in our node.
      Acked-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarIrui Wang <irui.wang@mediatek.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      5cd57605
    • Alexandre Courbot's avatar
      media: mtk-vcodec: venc: remove redundant code · b6c57d31
      Alexandre Courbot authored
      vidioc_try_fmt() does clamp height and width when called on the OUTPUT
      queue, so clamping them prior to calling this function is redundant. Set
      the queue's parameters after calling vidioc_try_fmt() so we can use the
      values it computed.
      Signed-off-by: default avatarAlexandre Courbot <acourbot@chromium.org>
      Signed-off-by: default avatarIrui Wang <irui.wang@mediatek.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      b6c57d31
    • Tomi Valkeinen's avatar
      media: v4l2-subdev: add subdev-wide state struct · 0d346d2a
      Tomi Valkeinen authored
      We have 'struct v4l2_subdev_pad_config' which contains configuration for
      a single pad used for the TRY functionality, and an array of those
      structs is passed to various v4l2_subdev_pad_ops.
      
      I was working on subdev internal routing between pads, and realized that
      there's no way to add TRY functionality for routes, which is not pad
      specific configuration. Adding a separate struct for try-route config
      wouldn't work either, as e.g. set-fmt needs to know the try-route
      configuration to propagate the settings.
      
      This patch adds a new struct, 'struct v4l2_subdev_state' (which at the
      moment only contains the v4l2_subdev_pad_config array) and the new
      struct is used in most of the places where v4l2_subdev_pad_config was
      used. All v4l2_subdev_pad_ops functions taking v4l2_subdev_pad_config
      are changed to instead take v4l2_subdev_state.
      
      The changes to drivers/media/v4l2-core/v4l2-subdev.c and
      include/media/v4l2-subdev.h were written by hand, and all the driver
      changes were done with the semantic patch below. The spatch needs to be
      applied to a select list of directories. I used the following shell
      commands to apply the spatch:
      
      dirs="drivers/media/i2c drivers/media/platform drivers/media/usb drivers/media/test-drivers/vimc drivers/media/pci drivers/staging/media"
      for dir in $dirs; do spatch -j8 --dir --include-headers --no-show-diff --in-place --sp-file v4l2-subdev-state.cocci $dir; done
      
      Note that Coccinelle chokes on a few drivers (gcc extensions?). With
      minor changes we can make Coccinelle run fine, and these changes can be
      reverted after spatch. The diff for these changes is:
      
      For drivers/media/i2c/s5k5baf.c:
      
      	@@ -1481,7 +1481,7 @@ static int s5k5baf_set_selection(struct v4l2_subdev *sd,
      	 				&s5k5baf_cis_rect,
      	 				v4l2_subdev_get_try_crop(sd, cfg, PAD_CIS),
      	 				v4l2_subdev_get_try_compose(sd, cfg, PAD_CIS),
      	-				v4l2_subdev_get_try_crop(sd, cfg, PAD_OUT)
      	+				v4l2_subdev_get_try_crop(sd, cfg, PAD_OUT),
      	 			};
      	 		s5k5baf_set_rect_and_adjust(rects, rtype, &sel->r);
      	 		return 0;
      
      For drivers/media/platform/s3c-camif/camif-capture.c:
      
      	@@ -1230,7 +1230,7 @@ static int s3c_camif_subdev_get_fmt(struct v4l2_subdev *sd,
      	 		*mf = camif->mbus_fmt;
      	 		break;
      
      	-	case CAMIF_SD_PAD_SOURCE_C...CAMIF_SD_PAD_SOURCE_P:
      	+	case CAMIF_SD_PAD_SOURCE_C:
      	 		/* crop rectangle at camera interface input */
      	 		mf->width = camif->camif_crop.width;
      	 		mf->height = camif->camif_crop.height;
      	@@ -1332,7 +1332,7 @@ static int s3c_camif_subdev_set_fmt(struct v4l2_subdev *sd,
      	 		}
      	 		break;
      
      	-	case CAMIF_SD_PAD_SOURCE_C...CAMIF_SD_PAD_SOURCE_P:
      	+	case CAMIF_SD_PAD_SOURCE_C:
      	 		/* Pixel format can be only changed on the sink pad. */
      	 		mf->code = camif->mbus_fmt.code;
      	 		mf->width = crop->width;
      
      The semantic patch is:
      
      // <smpl>
      
      // Change function parameter
      
      @@
      identifier func;
      identifier cfg;
      @@
      
       func(...,
      -   struct v4l2_subdev_pad_config *cfg
      +   struct v4l2_subdev_state *sd_state
          , ...)
       {
       <...
      - cfg
      + sd_state
       ...>
       }
      
      // Change function declaration parameter
      
      @@
      identifier func;
      identifier cfg;
      type T;
      @@
      T func(...,
      -   struct v4l2_subdev_pad_config *cfg
      +   struct v4l2_subdev_state *sd_state
          , ...);
      
      // Change function return value
      
      @@
      identifier func;
      @@
      - struct v4l2_subdev_pad_config
      + struct v4l2_subdev_state
       *func(...)
       {
          ...
       }
      
      // Change function declaration return value
      
      @@
      identifier func;
      @@
      - struct v4l2_subdev_pad_config
      + struct v4l2_subdev_state
       *func(...);
      
      // Some drivers pass a local pad_cfg for a single pad to a called function. Wrap it
      // inside a pad_state.
      
      @@
      identifier func;
      identifier pad_cfg;
      @@
      func(...)
      {
          ...
          struct v4l2_subdev_pad_config pad_cfg;
      +   struct v4l2_subdev_state pad_state = { .pads = &pad_cfg };
      
          <+...
      
      (
          v4l2_subdev_call
      |
          sensor_call
      |
          isi_try_fse
      |
          isc_try_fse
      |
          saa_call_all
      )
          (...,
      -   &pad_cfg
      +   &pad_state
          ,...)
      
          ...+>
      }
      
      // If the function uses fields from pad_config, access via state->pads
      
      @@
      identifier func;
      identifier state;
      @@
       func(...,
          struct v4l2_subdev_state *state
          , ...)
       {
          <...
      (
      -   state->try_fmt
      +   state->pads->try_fmt
      |
      -   state->try_crop
      +   state->pads->try_crop
      |
      -   state->try_compose
      +   state->pads->try_compose
      )
          ...>
      }
      
      // If the function accesses the filehandle, use fh->state instead
      
      @@
      struct v4l2_subdev_fh *fh;
      @@
      -    fh->pad
      +    fh->state
      
      @@
      struct v4l2_subdev_fh fh;
      @@
      -    fh.pad
      +    fh.state
      
      // Start of vsp1 specific
      
      @@
      @@
      struct vsp1_entity {
          ...
      -    struct v4l2_subdev_pad_config *config;
      +    struct v4l2_subdev_state *config;
          ...
      };
      
      @@
      symbol entity;
      @@
      vsp1_entity_init(...)
      {
          ...
          entity->config =
      -    v4l2_subdev_alloc_pad_config
      +    v4l2_subdev_alloc_state
          (&entity->subdev);
          ...
      }
      
      @@
      symbol entity;
      @@
      vsp1_entity_destroy(...)
      {
          ...
      -   v4l2_subdev_free_pad_config
      +   v4l2_subdev_free_state
          (entity->config);
          ...
      }
      
      @exists@
      identifier func =~ "(^vsp1.*)|(hsit_set_format)|(sru_enum_frame_size)|(sru_set_format)|(uif_get_selection)|(uif_set_selection)|(uds_enum_frame_size)|(uds_set_format)|(brx_set_format)|(brx_get_selection)|(histo_get_selection)|(histo_set_selection)|(brx_set_selection)";
      symbol config;
      @@
      func(...) {
          ...
      -    struct v4l2_subdev_pad_config *config;
      +    struct v4l2_subdev_state *config;
          ...
      }
      
      // End of vsp1 specific
      
      // Start of rcar specific
      
      @@
      identifier sd;
      identifier pad_cfg;
      @@
       rvin_try_format(...)
       {
          ...
      -   struct v4l2_subdev_pad_config *pad_cfg;
      +   struct v4l2_subdev_state *sd_state;
          ...
      -   pad_cfg = v4l2_subdev_alloc_pad_config(sd);
      +   sd_state = v4l2_subdev_alloc_state(sd);
          <...
      -   pad_cfg
      +   sd_state
          ...>
      -   v4l2_subdev_free_pad_config(pad_cfg);
      +   v4l2_subdev_free_state(sd_state);
          ...
       }
      
      // End of rcar specific
      
      // Start of rockchip specific
      
      @@
      identifier func =~ "(rkisp1_rsz_get_pad_fmt)|(rkisp1_rsz_get_pad_crop)|(rkisp1_rsz_register)";
      symbol rsz;
      symbol pad_cfg;
      @@
      
       func(...)
       {
      +   struct v4l2_subdev_state state = { .pads = rsz->pad_cfg };
          ...
      -   rsz->pad_cfg
      +   &state
          ...
       }
      
      @@
      identifier func =~ "(rkisp1_isp_get_pad_fmt)|(rkisp1_isp_get_pad_crop)";
      symbol isp;
      symbol pad_cfg;
      @@
      
       func(...)
       {
      +   struct v4l2_subdev_state state = { .pads = isp->pad_cfg };
          ...
      -   isp->pad_cfg
      +   &state
          ...
       }
      
      @@
      symbol rkisp1;
      symbol isp;
      symbol pad_cfg;
      @@
      
       rkisp1_isp_register(...)
       {
      +   struct v4l2_subdev_state state = { .pads = rkisp1->isp.pad_cfg };
          ...
      -   rkisp1->isp.pad_cfg
      +   &state
          ...
       }
      
      // End of rockchip specific
      
      // Start of tegra-video specific
      
      @@
      identifier sd;
      identifier pad_cfg;
      @@
       __tegra_channel_try_format(...)
       {
          ...
      -   struct v4l2_subdev_pad_config *pad_cfg;
      +   struct v4l2_subdev_state *sd_state;
          ...
      -   pad_cfg = v4l2_subdev_alloc_pad_config(sd);
      +   sd_state = v4l2_subdev_alloc_state(sd);
          <...
      -   pad_cfg
      +   sd_state
          ...>
      -   v4l2_subdev_free_pad_config(pad_cfg);
      +   v4l2_subdev_free_state(sd_state);
          ...
       }
      
      @@
      identifier sd_state;
      @@
       __tegra_channel_try_format(...)
       {
          ...
          struct v4l2_subdev_state *sd_state;
          <...
      -   sd_state->try_crop
      +   sd_state->pads->try_crop
          ...>
       }
      
      // End of tegra-video specific
      
      // </smpl>
      Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ideasonboard.com>
      Acked-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
      Acked-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      0d346d2a
    • Gustavo A. R. Silva's avatar
      media: venus: hfi_msgs.h: Replace one-element arrays with flexible-array members · 6f2f49ae
      Gustavo A. R. Silva authored
      There is a regular need in the kernel to provide a way to declare having
      a dynamically sized set of trailing elements in a structure. Kernel code
      should always use “flexible array members”[1] for these cases. The older
      style of one-element or zero-length arrays should no longer be used[2].
      
      Use flexible-array members in struct hfi_msg_sys_property_info_pkt and
      hfi_msg_session_property_info_pkt instead of one-element arrays, and
      refactor the code accordingly.
      
      Also, this helps with the ongoing efforts to enable -Warray-bounds by
      fixing the following warnings:
      
        CC [M]  drivers/media/platform/qcom/venus/hfi_msgs.o
      drivers/media/platform/qcom/venus/hfi_msgs.c: In function ‘hfi_sys_property_info’:
      drivers/media/platform/qcom/venus/hfi_msgs.c:246:35: warning: array subscript 1 is above array bounds of ‘u32[1]’ {aka ‘unsigned int[1]’} [-Warray-bounds]
        246 |  if (req_bytes < 128 || !pkt->data[1] || pkt->num_properties > 1)
            |                          ~~~~~~~~~^~~
      drivers/media/platform/qcom/venus/hfi_msgs.c: In function ‘hfi_session_prop_info’:
      drivers/media/platform/qcom/venus/hfi_msgs.c:342:62: warning: array subscript 1 is above array bounds of ‘u32[1]’ {aka ‘unsigned int[1]’} [-Warray-bounds]
        342 |  if (!req_bytes || req_bytes % sizeof(*buf_req) || !pkt->data[1])
            |                                                     ~~~~~~~~~^~~
      
      [1] https://en.wikipedia.org/wiki/Flexible_array_member
      [2] https://www.kernel.org/doc/html/v5.9/process/deprecated.html#zero-length-and-one-element-arrays
      
      Link: https://github.com/KSPP/linux/issues/79
      Link: https://github.com/KSPP/linux/issues/109Co-developed-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      Signed-off-by: default avatarStanimir Varbanov <stanimir.varbanov@linaro.org>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      6f2f49ae
    • Gustavo A. R. Silva's avatar
      media: venus: hfi_cmds: Fix packet size calculation · c73c23f3
      Gustavo A. R. Silva authored
      Now that a one-element array was replaced with a flexible-array member
      in struct hfi_sys_set_property_pkt, use the struct_size() helper to
      correctly calculate the packet size.
      
      Fixes: 701e10b3fd9f ("media: venus: hfi_cmds.h: Replace one-element array with flexible-array member")
      Signed-off-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
      Signed-off-by: default avatarStanimir Varbanov <stanimir.varbanov@linaro.org>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
      c73c23f3