Re: [PATCH 59/60] drm/xen: Add support for the nomodeset kernel parameter

2021-12-14 Thread Oleksandr Andrushchenko
Hi, Javier!

On 15.12.21 03:00, Javier Martinez Canillas wrote:
> According to disable Documentation/admin-guide/kernel-parameters.txt, this
> parameter can be used to disable kernel modesetting.
>
> DRM drivers will not perform display-mode changes or accelerated rendering
> and only the systewm system framebuffer will be available if it was set-up.
s/systewm system/system
>
> But only a few DRM drivers currently check for nomodeset, make this driver
> to also support the command line parameter.
>
> Signed-off-by: Javier Martinez Canillas 
> ---
>
>   drivers/gpu/drm/xen/xen_drm_front.c | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/xen/xen_drm_front.c 
> b/drivers/gpu/drm/xen/xen_drm_front.c
> index 434064c820e8..20d11ea79e0f 100644
> --- a/drivers/gpu/drm/xen/xen_drm_front.c
> +++ b/drivers/gpu/drm/xen/xen_drm_front.c
> @@ -495,6 +495,9 @@ static int xen_drm_drv_init(struct xen_drm_front_info 
> *front_info)
>   struct drm_device *drm_dev;
>   int ret;
>   
> + if (drm_firmware_drivers_only())
This is not yet in the upstream kernel, right?
> + return -ENODEV;
> +
>   DRM_INFO("Creating %s\n", xen_drm_driver.desc);
>   
>   drm_info = kzalloc(sizeof(*drm_info), GFP_KERNEL);
With the commit message fixed:
Reviewed-by: Oleksandr Andrushchenko 

Thank you,
Oleksandr

[PATCH v1, 12/12] media: mtk-vcodec: Add h264 slice api driver for mt8192

2021-12-14 Thread Yunfei Dong
From: Yunfei Dong 

Adds h264 lat and core driver for mt8192.

Signed-off-by: Yunfei Dong 
---
 drivers/media/platform/mtk-vcodec/Makefile|   1 +
 .../mtk-vcodec/vdec/vdec_h264_req_lat_if.c| 620 ++
 .../media/platform/mtk-vcodec/vdec_drv_if.c   |   8 +-
 .../media/platform/mtk-vcodec/vdec_drv_if.h   |   1 +
 include/linux/remoteproc/mtk_scp.h|   2 +
 5 files changed, 631 insertions(+), 1 deletion(-)
 create mode 100644 
drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_lat_if.c

diff --git a/drivers/media/platform/mtk-vcodec/Makefile 
b/drivers/media/platform/mtk-vcodec/Makefile
index 3f41d748eee5..1777d7606f0d 100644
--- a/drivers/media/platform/mtk-vcodec/Makefile
+++ b/drivers/media/platform/mtk-vcodec/Makefile
@@ -10,6 +10,7 @@ mtk-vcodec-dec-y := vdec/vdec_h264_if.o \
vdec/vdec_vp9_if.o \
vdec/vdec_h264_req_if.o \
vdec/vdec_h264_req_common.o \
+   vdec/vdec_h264_req_lat_if.o \
mtk_vcodec_dec_drv.o \
vdec_drv_if.o \
vdec_vpu_if.o \
diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_lat_if.c 
b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_lat_if.c
new file mode 100644
index ..403d7df00e1d
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_lat_if.c
@@ -0,0 +1,620 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2021 MediaTek Inc.
+ * Author: Yunfei Dong 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "../mtk_vcodec_util.h"
+#include "../mtk_vcodec_dec.h"
+#include "../mtk_vcodec_intr.h"
+#include "../vdec_drv_base.h"
+#include "../vdec_drv_if.h"
+#include "../vdec_vpu_if.h"
+#include "vdec_h264_req_common.h"
+
+/**
+ * enum vdec_h264_core_dec_err_type  - core decode error type
+ */
+enum vdec_h264_core_dec_err_type {
+   TRANS_BUFFER_FULL = 1,
+   SLICE_HEADER_FULL,
+};
+
+/**
+ * struct vdec_h264_slice_lat_dec_param  - parameters for decode current frame
+ * @sps : h264 sps syntax parameters
+ * @pps : h264 pps syntax parameters
+ * @slice_header: h264 slice header syntax parameters
+ * @scaling_matrix : h264 scaling list parameters
+ * @decode_params : decoder parameters of each frame used for hardware decode
+ * @h264_dpb_info : dpb reference list
+ */
+struct vdec_h264_slice_lat_dec_param {
+   struct mtk_h264_sps_param sps;
+   struct mtk_h264_pps_param pps;
+   struct mtk_h264_slice_hd_param slice_header;
+   struct slice_api_h264_scaling_matrix scaling_matrix;
+   struct slice_api_h264_decode_param decode_params;
+   struct mtk_h264_dpb_info h264_dpb_info[V4L2_H264_NUM_DPB_ENTRIES];
+};
+
+/**
+ * struct vdec_h264_slice_info - decode information
+ * @nal_info: nal info of current picture
+ * @timeout : Decode timeout: 1 timeout, 0 no timeount
+ * @bs_buf_size : bitstream size
+ * @bs_buf_addr : bitstream buffer dma address
+ * @y_fb_dma: Y frame buffer dma address
+ * @c_fb_dma: C frame buffer dma address
+ * @vdec_fb_va  : VDEC frame buffer struct virtual address
+ * @crc : Used to check whether hardware's status is right
+ */
+struct vdec_h264_slice_info {
+   uint16_t nal_info;
+   uint16_t timeout;
+   uint32_t bs_buf_size;
+   uint64_t bs_buf_addr;
+   uint64_t y_fb_dma;
+   uint64_t c_fb_dma;
+   uint64_t vdec_fb_va;
+   uint32_t crc[8];
+};
+
+/**
+ * struct vdec_h264_slice_vsi - shared memory for decode information exchange
+ *between VPU and Host. The memory is allocated by VPU then mapping to
+ *Host in vdec_h264_slice_init() and freed in vdec_h264_slice_deinit()
+ *by VPU. AP-W/R : AP is writer/reader on this item. VPU-W/R: VPU is
+ *write/reader on this item.
+ * @wdma_err_addr   : wdma error dma address
+ * @wdma_start_addr : wdma start dma address
+ * @wdma_end_addr   : wdma end dma address
+ * @slice_bc_start_addr : slice bc start dma address
+ * @slice_bc_end_addr   : slice bc end dma address
+ * @row_info_start_addr : row info start dma address
+ * @row_info_end_addr   : row info end dma address
+ * @trans_start : trans start dma address
+ * @trans_end   : trans end dma address
+ * @wdma_end_addr_offset: wdma end address offset
+ * @mv_buf_dma  : HW working motion vector buffer
+ *dma address (AP-W, VPU-R)
+ * @dec : decode information (AP-R, VPU-W)
+ * @h264_slice_params   : decode parameters for hw used
+ */
+struct vdec_h264_slice_vsi {
+   /* LAT dec addr */
+   uint64_t wdma_err_addr;
+   uint64_t wdma_start_addr;
+   uint64_t wdma_end_addr;
+   uint64_t slice_bc_start_addr;
+   uint64_t slice_bc_end_addr;
+   uint64_t row_info_start_addr;
+   uint64_t row_info_end_addr;
+   uint64_t trans_start;
+   uint64_t trans_end;
+   uint64_t wdma_end_addr_offset;
+
+   uint64_t 

[PATCH v1, 09/12] media: mtk-vcodec: disable vp8 4K capability

2021-12-14 Thread Yunfei Dong
From: Yunfei Dong 

For vp8 not support 4K, need to disable it.

Signed-off-by: Yunfei Dong 
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
index 0b14f816bf58..0317a9930de1 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
@@ -534,7 +534,8 @@ static int vidioc_enum_framesizes(struct file *file, void 
*priv,
fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE;
fsize->stepwise = dec_pdata->vdec_framesizes[i].stepwise;
if (!(ctx->dev->dec_capability &
-   VCODEC_CAPABILITY_4K_DISABLED)) {
+   VCODEC_CAPABILITY_4K_DISABLED) &&
+   fsize->pixel_format != V4L2_PIX_FMT_VP8_FRAME) {
mtk_v4l2_debug(3, "4K is enabled");
fsize->stepwise.max_width =
VCODEC_DEC_4K_CODED_WIDTH;
-- 
2.25.1



[PATCH v1, 08/12] media: mtk-vcodec: Add format to support MT21C

2021-12-14 Thread Yunfei Dong
From: Yunfei Dong 

Needs to use mediatek compressed mode for mt8192 decoder.

Signed-off-by: Yunfei Dong 
---
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c   | 7 ++-
 drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h | 1 +
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c
index 01bb96f3b30e..21895fbed4c5 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c
@@ -81,7 +81,7 @@ static const struct mtk_stateless_control 
mtk_stateless_controls[] = {
 
 #define NUM_CTRLS ARRAY_SIZE(mtk_stateless_controls)
 
-static struct mtk_video_fmt mtk_video_formats[2];
+static struct mtk_video_fmt mtk_video_formats[3];
 static struct mtk_codec_framesizes mtk_vdec_framesizes[1];
 
 static struct mtk_video_fmt default_out_format;
@@ -361,6 +361,7 @@ static void mtk_vcodec_add_formats(unsigned int fourcc,
num_framesizes++;
break;
case V4L2_PIX_FMT_MM21:
+   case V4L2_PIX_FMT_MT21C:
mtk_video_formats[count_formats].fourcc = fourcc;
mtk_video_formats[count_formats].type = MTK_FMT_FRAME;
mtk_video_formats[count_formats].num_planes = 2;
@@ -387,6 +388,10 @@ static void mtk_vcodec_get_supported_formats(struct 
mtk_vcodec_ctx *ctx)
mtk_vcodec_add_formats(V4L2_PIX_FMT_MM21, ctx);
cap_format_count++;
}
+   if (ctx->dev->dec_capability & MTK_VDEC_FORMAT_MT21C) {
+   mtk_vcodec_add_formats(V4L2_PIX_FMT_MT21C, ctx);
+   cap_format_count++;
+   }
if (ctx->dev->dec_capability & MTK_VDEC_FORMAT_H264_SLICE) {
mtk_vcodec_add_formats(V4L2_PIX_FMT_H264_SLICE, ctx);
out_format_count++;
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
index 077352453759..773887578454 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
@@ -362,6 +362,7 @@ enum mtk_vdec_hw_arch {
  */
 enum mtk_vdec_format_types {
MTK_VDEC_FORMAT_MM21 = 0x20,
+   MTK_VDEC_FORMAT_MT21C = 0x40,
MTK_VDEC_FORMAT_H264_SLICE = 0x100,
 };
 
-- 
2.25.1



[PATCH v1, 11/12] media: mtk-vcodec: Extract H264 common code

2021-12-14 Thread Yunfei Dong
From: Yunfei Dong 

Mt8192 can use some of common code with mt8183. Moves them to
a new file in order to reuse.

Signed-off-by: Yunfei Dong 
---
 drivers/media/platform/mtk-vcodec/Makefile|   1 +
 .../mtk-vcodec/vdec/vdec_h264_req_common.c| 303 ++
 .../mtk-vcodec/vdec/vdec_h264_req_common.h| 247 +++
 .../mtk-vcodec/vdec/vdec_h264_req_if.c| 386 +-
 4 files changed, 571 insertions(+), 366 deletions(-)
 create mode 100644 
drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_common.c
 create mode 100644 
drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_common.h

diff --git a/drivers/media/platform/mtk-vcodec/Makefile 
b/drivers/media/platform/mtk-vcodec/Makefile
index 359619653a0e..3f41d748eee5 100644
--- a/drivers/media/platform/mtk-vcodec/Makefile
+++ b/drivers/media/platform/mtk-vcodec/Makefile
@@ -9,6 +9,7 @@ mtk-vcodec-dec-y := vdec/vdec_h264_if.o \
vdec/vdec_vp8_if.o \
vdec/vdec_vp9_if.o \
vdec/vdec_h264_req_if.o \
+   vdec/vdec_h264_req_common.o \
mtk_vcodec_dec_drv.o \
vdec_drv_if.o \
vdec_vpu_if.o \
diff --git a/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_common.c 
b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_common.c
new file mode 100644
index ..7e248e247628
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_common.c
@@ -0,0 +1,303 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2021 MediaTek Inc.
+ * Author: Yunfei Dong 
+ */
+
+#include "vdec_h264_req_common.h"
+
+/* get used parameters for sps/pps */
+#define GET_MTK_VDEC_FLAG(cond, flag) \
+   { dst_param->cond = ((src_param->flags & flag) ? (1) : (0)); }
+#define GET_MTK_VDEC_PARAM(param) \
+   { dst_param->param = src_param->param; }
+
+void *mtk_vdec_h264_get_ctrl_ptr(struct mtk_vcodec_ctx *ctx, int id)
+{
+   struct v4l2_ctrl *ctrl = v4l2_ctrl_find(>ctrl_hdl, id);
+
+   return ctrl->p_cur.p;
+}
+
+void mtk_vdec_h264_fill_dpb_info(struct mtk_vcodec_ctx *ctx,
+   struct slice_api_h264_decode_param *decode_params,
+   struct mtk_h264_dpb_info *h264_dpb_info)
+{
+   struct vb2_queue *vq;
+   struct vb2_buffer *vb;
+   struct vb2_v4l2_buffer *vb2_v4l2;
+   int index;
+
+   vq = v4l2_m2m_get_vq(ctx->m2m_ctx, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE);
+
+   for (index = 0; index < V4L2_H264_NUM_DPB_ENTRIES; index++) {
+   const struct slice_h264_dpb_entry *dpb;
+   int vb2_index;
+
+   dpb = _params->dpb[index];
+   if (!(dpb->flags & V4L2_H264_DPB_ENTRY_FLAG_ACTIVE)) {
+   h264_dpb_info[index].reference_flag = 0;
+   continue;
+   }
+
+   vb2_index = vb2_find_timestamp(vq, dpb->reference_ts, 0);
+   if (vb2_index < 0) {
+   dev_err(>dev->plat_dev->dev,
+   "Reference invalid: dpb_index(%d) 
reference_ts(%lld)",
+   index, dpb->reference_ts);
+   continue;
+   }
+
+   /* 1 for short term reference, 2 for long term reference */
+   if (!(dpb->flags & V4L2_H264_DPB_ENTRY_FLAG_LONG_TERM))
+   h264_dpb_info[index].reference_flag = 1;
+   else
+   h264_dpb_info[index].reference_flag = 2;
+
+   vb = vq->bufs[vb2_index];
+   vb2_v4l2 = container_of(vb, struct vb2_v4l2_buffer, vb2_buf);
+   h264_dpb_info[index].field = vb2_v4l2->field;
+
+   h264_dpb_info[index].y_dma_addr =
+   vb2_dma_contig_plane_dma_addr(vb, 0);
+   if (ctx->q_data[MTK_Q_DATA_DST].fmt->num_planes == 2)
+   h264_dpb_info[index].c_dma_addr =
+   vb2_dma_contig_plane_dma_addr(vb, 1);
+   else
+   h264_dpb_info[index].c_dma_addr =
+   h264_dpb_info[index].y_dma_addr +
+   ctx->picinfo.fb_sz[0];
+   }
+}
+
+void mtk_vdec_h264_copy_sps_params(struct mtk_h264_sps_param *dst_param,
+   const struct v4l2_ctrl_h264_sps *src_param)
+{
+   GET_MTK_VDEC_PARAM(chroma_format_idc);
+   GET_MTK_VDEC_PARAM(bit_depth_luma_minus8);
+   GET_MTK_VDEC_PARAM(bit_depth_chroma_minus8);
+   GET_MTK_VDEC_PARAM(log2_max_frame_num_minus4);
+   GET_MTK_VDEC_PARAM(pic_order_cnt_type);
+   GET_MTK_VDEC_PARAM(log2_max_pic_order_cnt_lsb_minus4);
+   GET_MTK_VDEC_PARAM(max_num_ref_frames);
+   GET_MTK_VDEC_PARAM(pic_width_in_mbs_minus1);
+   GET_MTK_VDEC_PARAM(pic_height_in_map_units_minus1);
+
+   GET_MTK_VDEC_FLAG(separate_colour_plane_flag,
+   V4L2_H264_SPS_FLAG_SEPARATE_COLOUR_PLANE);
+   GET_MTK_VDEC_FLAG(qpprime_y_zero_transform_bypass_flag,
+   

[PATCH v1, 07/12] media: mtk-vcodec: Refactor supported vdec formats and framesizes

2021-12-14 Thread Yunfei Dong
From: Yunfei Dong 

Supported output and capture format types for mt8192 are different
with mt8183. Needs to get format types according to decoder capability.

Signed-off-by: Yunfei Dong 
---
 .../platform/mtk-vcodec/mtk_vcodec_dec.c  |   8 +-
 .../mtk-vcodec/mtk_vcodec_dec_stateful.c  |  13 +-
 .../mtk-vcodec/mtk_vcodec_dec_stateless.c | 117 +-
 .../platform/mtk-vcodec/mtk_vcodec_drv.h  |  13 +-
 4 files changed, 107 insertions(+), 44 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
index ad7cb9d4f280..0b14f816bf58 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
@@ -26,7 +26,7 @@ mtk_vdec_find_format(struct v4l2_format *f,
const struct mtk_video_fmt *fmt;
unsigned int k;
 
-   for (k = 0; k < dec_pdata->num_formats; k++) {
+   for (k = 0; k < *dec_pdata->num_formats; k++) {
fmt = _pdata->vdec_formats[k];
if (fmt->fourcc == f->fmt.pix_mp.pixelformat)
return fmt;
@@ -527,7 +527,7 @@ static int vidioc_enum_framesizes(struct file *file, void 
*priv,
if (fsize->index != 0)
return -EINVAL;
 
-   for (i = 0; i < dec_pdata->num_framesizes; ++i) {
+   for (i = 0; i < *dec_pdata->num_framesizes; ++i) {
if (fsize->pixel_format != dec_pdata->vdec_framesizes[i].fourcc)
continue;
 
@@ -566,7 +566,7 @@ static int vidioc_enum_fmt(struct v4l2_fmtdesc *f, void 
*priv,
const struct mtk_video_fmt *fmt;
int i, j = 0;
 
-   for (i = 0; i < dec_pdata->num_formats; i++) {
+   for (i = 0; i < *dec_pdata->num_formats; i++) {
if (output_queue &&
dec_pdata->vdec_formats[i].type != MTK_FMT_DEC)
continue;
@@ -579,7 +579,7 @@ static int vidioc_enum_fmt(struct v4l2_fmtdesc *f, void 
*priv,
++j;
}
 
-   if (i == dec_pdata->num_formats)
+   if (i == *dec_pdata->num_formats)
return -EINVAL;
 
fmt = _pdata->vdec_formats[i];
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateful.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateful.c
index 7966c132be8f..3f33beb9c551 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateful.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateful.c
@@ -37,7 +37,9 @@ static const struct mtk_video_fmt mtk_video_formats[] = {
},
 };
 
-#define NUM_FORMATS ARRAY_SIZE(mtk_video_formats)
+static const unsigned int num_supported_formats =
+   ARRAY_SIZE(mtk_video_formats);
+
 #define DEFAULT_OUT_FMT_IDX 0
 #define DEFAULT_CAP_FMT_IDX 3
 
@@ -59,7 +61,8 @@ static const struct mtk_codec_framesizes 
mtk_vdec_framesizes[] = {
},
 };
 
-#define NUM_SUPPORTED_FRAMESIZE ARRAY_SIZE(mtk_vdec_framesizes)
+static const unsigned int num_supported_framesize =
+   ARRAY_SIZE(mtk_vdec_framesizes);
 
 /*
  * This function tries to clean all display buffers, the buffers will return
@@ -235,7 +238,7 @@ static void mtk_vdec_update_fmt(struct mtk_vcodec_ctx *ctx,
unsigned int k;
 
dst_q_data = >q_data[MTK_Q_DATA_DST];
-   for (k = 0; k < NUM_FORMATS; k++) {
+   for (k = 0; k < num_supported_formats; k++) {
fmt = _video_formats[k];
if (fmt->fourcc == pixelformat) {
mtk_v4l2_debug(1, "Update cap fourcc(%d -> %d)",
@@ -617,11 +620,11 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8173_pdata = {
.ctrls_setup = mtk_vcodec_dec_ctrls_setup,
.vdec_vb2_ops = _vdec_frame_vb2_ops,
.vdec_formats = mtk_video_formats,
-   .num_formats = NUM_FORMATS,
+   .num_formats = _supported_formats,
.default_out_fmt = _video_formats[DEFAULT_OUT_FMT_IDX],
.default_cap_fmt = _video_formats[DEFAULT_CAP_FMT_IDX],
.vdec_framesizes = mtk_vdec_framesizes,
-   .num_framesizes = NUM_SUPPORTED_FRAMESIZE,
+   .num_framesizes = _supported_framesize,
.worker = mtk_vdec_worker,
.flush_decoder = mtk_vdec_flush_decoder,
.is_subdev_supported = false,
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c
index f3036c3f223b..01bb96f3b30e 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c
@@ -81,33 +81,23 @@ static const struct mtk_stateless_control 
mtk_stateless_controls[] = {
 
 #define NUM_CTRLS ARRAY_SIZE(mtk_stateless_controls)
 
-static const struct mtk_video_fmt mtk_video_formats[] = {
-   {
-   .fourcc = V4L2_PIX_FMT_H264_SLICE,
-   .type = MTK_FMT_DEC,
-   .num_planes = 1,
-   },
-   {
-   .fourcc = V4L2_PIX_FMT_MM21,
-   

[PATCH v1, 10/12] media: mtk-vcodec: Fix v4l2-compliance fail

2021-12-14 Thread Yunfei Dong
From: Yunfei Dong 

Need to use default pic info when get pic info fail.

Signed-off-by: Yunfei Dong 
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
index 0317a9930de1..4533cb44551d 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
@@ -480,11 +480,14 @@ static int vidioc_vdec_s_fmt(struct file *file, void 
*priv,
ctx->picinfo.pic_w = pix_mp->width;
ctx->picinfo.pic_h = pix_mp->height;
 
+   /*
+* If get pic info fail, need to use the default pic info 
params, or
+* v4l2-compliance will fail
+*/
ret = vdec_if_get_param(ctx, GET_PARAM_PIC_INFO, >picinfo);
if (ret) {
mtk_v4l2_err("[%d]Error!! Get GET_PARAM_PICTURE_INFO 
Fail",
 ctx->id);
-   return -EINVAL;
}
 
ctx->last_decoded_picinfo = ctx->picinfo;
-- 
2.25.1



[PATCH v1, 06/12] media: mtk-vcodec: Refactor get and put capture buffer flow

2021-12-14 Thread Yunfei Dong
From: Yunfei Dong 

For lat and core decode in parallel, need to get capture buffer
when core start to decode and put put capture buffer to display
list when core decode done.

Signed-off-by: Yunfei Dong 
---
 .../mtk-vcodec/mtk_vcodec_dec_stateless.c | 122 --
 .../platform/mtk-vcodec/mtk_vcodec_drv.h  |   5 +-
 .../mtk-vcodec/vdec/vdec_h264_req_if.c|  16 ++-
 3 files changed, 103 insertions(+), 40 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c
index 0d19b0f67fd6..f3036c3f223b 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c
@@ -108,38 +108,89 @@ static const struct mtk_codec_framesizes 
mtk_vdec_framesizes[] = {
 
 #define NUM_SUPPORTED_FRAMESIZE ARRAY_SIZE(mtk_vdec_framesizes)
 
-static void mtk_vdec_stateless_set_dst_payload(struct mtk_vcodec_ctx *ctx,
-  struct vdec_fb *fb)
+static void mtk_vdec_stateless_out_to_done(struct mtk_vcodec_ctx *ctx,
+  struct mtk_vcodec_mem *bs, int error)
 {
-   struct mtk_video_dec_buf *vdec_frame_buf =
-   container_of(fb, struct mtk_video_dec_buf, frame_buffer);
-   struct vb2_v4l2_buffer *vb = _frame_buf->m2m_buf.vb;
-   unsigned int cap_y_size = ctx->q_data[MTK_Q_DATA_DST].sizeimage[0];
+   struct mtk_video_dec_buf *out_buf;
+   struct vb2_v4l2_buffer *vb;
 
-   vb2_set_plane_payload(>vb2_buf, 0, cap_y_size);
-   if (ctx->q_data[MTK_Q_DATA_DST].fmt->num_planes == 2) {
-   unsigned int cap_c_size =
-   ctx->q_data[MTK_Q_DATA_DST].sizeimage[1];
+   if (!bs) {
+   mtk_v4l2_err("Free bitstream buffer fail.");
+   return;
+   }
+   out_buf = container_of(bs, struct mtk_video_dec_buf, bs_buffer);
+   vb = _buf->m2m_buf.vb;
+
+   mtk_v4l2_debug(2,
+   "Free bitsteam buffer id = %d to done_list",
+   vb->vb2_buf.index);
+
+   v4l2_m2m_src_buf_remove(ctx->m2m_ctx);
+   if (error) {
+   v4l2_m2m_buf_done(vb, VB2_BUF_STATE_ERROR);
+   if (error == -EIO)
+   out_buf->error = true;
+   } else {
+   v4l2_m2m_buf_done(vb, VB2_BUF_STATE_DONE);
+   }
+}
 
-   vb2_set_plane_payload(>vb2_buf, 1, cap_c_size);
+static void mtk_vdec_stateless_cap_to_disp(struct mtk_vcodec_ctx *ctx,
+  struct vdec_fb *fb, int error)
+{
+   struct mtk_video_dec_buf *vdec_frame_buf;
+   struct vb2_v4l2_buffer *vb;
+   unsigned int cap_y_size, cap_c_size;
+
+   if (!fb) {
+   mtk_v4l2_err("Free frame buffer fail.");
+   return;
}
+   vdec_frame_buf = container_of(fb, struct mtk_video_dec_buf,
+ frame_buffer);
+   vb = _frame_buf->m2m_buf.vb;
+
+   cap_y_size = ctx->q_data[MTK_Q_DATA_DST].sizeimage[0];
+   cap_c_size = ctx->q_data[MTK_Q_DATA_DST].sizeimage[1];
+
+   v4l2_m2m_dst_buf_remove(ctx->m2m_ctx);
+
+   vb2_set_plane_payload(>vb2_buf, 0, cap_y_size);
+   if (ctx->q_data[MTK_Q_DATA_DST].fmt->num_planes == 2)
+   vb2_set_plane_payload(>vb2_buf, 1, cap_c_size);
+
+   mtk_v4l2_debug(2,
+   "Free frame buffer id = %d to done_list",
+   vb->vb2_buf.index);
+   if (error)
+   v4l2_m2m_buf_done(vb, VB2_BUF_STATE_ERROR);
+   else
+   v4l2_m2m_buf_done(vb, VB2_BUF_STATE_DONE);
 }
 
-static struct vdec_fb *vdec_get_cap_buffer(struct mtk_vcodec_ctx *ctx,
-  struct vb2_v4l2_buffer *vb2_v4l2)
+static struct vdec_fb *vdec_get_cap_buffer(struct mtk_vcodec_ctx *ctx)
 {
-   struct mtk_video_dec_buf *framebuf =
-   container_of(vb2_v4l2, struct mtk_video_dec_buf, m2m_buf.vb);
-   struct vdec_fb *pfb = >frame_buffer;
-   struct vb2_buffer *dst_buf = _v4l2->vb2_buf;
+   struct mtk_video_dec_buf *framebuf;
+   struct vb2_v4l2_buffer *vb2_v4l2;
+   struct vb2_buffer *dst_buf;
+   struct vdec_fb *pfb;
+
+   vb2_v4l2 = v4l2_m2m_next_dst_buf(ctx->m2m_ctx);
+   if (!vb2_v4l2) {
+   mtk_v4l2_debug(1, "[%d] dst_buf empty!!", ctx->id);
+   return NULL;
+   }
+
+   dst_buf = _v4l2->vb2_buf;
+   framebuf = container_of(vb2_v4l2, struct mtk_video_dec_buf, m2m_buf.vb);
 
pfb = >frame_buffer;
-   pfb->base_y.va = NULL;
+   pfb->base_y.va = vb2_plane_vaddr(dst_buf, 0);
pfb->base_y.dma_addr = vb2_dma_contig_plane_dma_addr(dst_buf, 0);
pfb->base_y.size = ctx->q_data[MTK_Q_DATA_DST].sizeimage[0];
 
if (ctx->q_data[MTK_Q_DATA_DST].fmt->num_planes == 2) {
-   pfb->base_c.va = NULL;
+   pfb->base_c.va = 

[PATCH v1, 05/12] media: mtk-vcodec: Call v4l2_m2m_set_dst_buffered() set capture buffer buffered

2021-12-14 Thread Yunfei Dong
From: Yunfei Dong 

For lat and core architecture, just need to get output buffer for lat
decode. For core hardware need to get lat's message and capture buffer.
In order to let lat and core decode in parallel, need to set capture
buffer buffered.

Signed-off-by: Yunfei Dong 
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c
index 1a4013f4fb83..0d19b0f67fd6 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c
@@ -315,6 +315,9 @@ static void mtk_init_vdec_params(struct mtk_vcodec_ctx *ctx)
src_vq = v4l2_m2m_get_vq(ctx->m2m_ctx,
 V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE);
 
+   if (ctx->dev->vdec_pdata->hw_arch != MTK_VDEC_PURE_SINGLE_CORE)
+   v4l2_m2m_set_dst_buffered(ctx->m2m_ctx, 1);
+
/* Support request api for output plane */
src_vq->supports_requests = true;
src_vq->requires_requests = true;
-- 
2.25.1



[PATCH v1, 04/12] media: mtk-vcodec: Read max resolution from dec_capability

2021-12-14 Thread Yunfei Dong
From: Yunfei Dong 

Reads supported max resolution from dec_capability.

Signed-off-by: Yunfei Dong 
---
 .../platform/mtk-vcodec/mtk_vcodec_dec.c  | 31 +++
 .../platform/mtk-vcodec/mtk_vcodec_drv.h  |  4 +++
 2 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
index 87891ebd7246..ad7cb9d4f280 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
@@ -152,13 +152,15 @@ void mtk_vcodec_dec_set_default_params(struct 
mtk_vcodec_ctx *ctx)
q_data->coded_height = DFT_CFG_HEIGHT;
q_data->fmt = ctx->dev->vdec_pdata->default_cap_fmt;
q_data->field = V4L2_FIELD_NONE;
+   ctx->max_width = MTK_VDEC_MAX_W;
+   ctx->max_height = MTK_VDEC_MAX_H;
 
v4l_bound_align_image(_data->coded_width,
MTK_VDEC_MIN_W,
-   MTK_VDEC_MAX_W, 4,
+   ctx->max_width, 4,
_data->coded_height,
MTK_VDEC_MIN_H,
-   MTK_VDEC_MAX_H, 5, 6);
+   ctx->max_height, 5, 6);
 
q_data->sizeimage[0] = q_data->coded_width * q_data->coded_height;
q_data->bytesperline[0] = q_data->coded_width;
@@ -217,17 +219,17 @@ static int vidioc_vdec_subscribe_evt(struct v4l2_fh *fh,
}
 }
 
-static int vidioc_try_fmt(struct v4l2_format *f,
- const struct mtk_video_fmt *fmt)
+static int vidioc_try_fmt(struct mtk_vcodec_ctx *ctx,
+   struct v4l2_format *f, const struct mtk_video_fmt *fmt)
 {
struct v4l2_pix_format_mplane *pix_fmt_mp = >fmt.pix_mp;
 
pix_fmt_mp->field = V4L2_FIELD_NONE;
 
pix_fmt_mp->width =
-   clamp(pix_fmt_mp->width, MTK_VDEC_MIN_W, MTK_VDEC_MAX_W);
+   clamp(pix_fmt_mp->width, MTK_VDEC_MIN_W, ctx->max_width);
pix_fmt_mp->height =
-   clamp(pix_fmt_mp->height, MTK_VDEC_MIN_H, MTK_VDEC_MAX_H);
+   clamp(pix_fmt_mp->height, MTK_VDEC_MIN_H, ctx->max_height);
 
if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
pix_fmt_mp->num_planes = 1;
@@ -245,16 +247,16 @@ static int vidioc_try_fmt(struct v4l2_format *f,
tmp_h = pix_fmt_mp->height;
v4l_bound_align_image(_fmt_mp->width,
MTK_VDEC_MIN_W,
-   MTK_VDEC_MAX_W, 6,
+   ctx->max_width, 6,
_fmt_mp->height,
MTK_VDEC_MIN_H,
-   MTK_VDEC_MAX_H, 6, 9);
+   ctx->max_height, 6, 9);
 
if (pix_fmt_mp->width < tmp_w &&
-   (pix_fmt_mp->width + 64) <= MTK_VDEC_MAX_W)
+   (pix_fmt_mp->width + 64) <= ctx->max_width)
pix_fmt_mp->width += 64;
if (pix_fmt_mp->height < tmp_h &&
-   (pix_fmt_mp->height + 64) <= MTK_VDEC_MAX_H)
+   (pix_fmt_mp->height + 64) <= ctx->max_height)
pix_fmt_mp->height += 64;
 
mtk_v4l2_debug(0,
@@ -294,7 +296,7 @@ static int vidioc_try_fmt_vid_cap_mplane(struct file *file, 
void *priv,
fmt = mtk_vdec_find_format(f, dec_pdata);
}
 
-   return vidioc_try_fmt(f, fmt);
+   return vidioc_try_fmt(ctx, f, fmt);
 }
 
 static int vidioc_try_fmt_vid_out_mplane(struct file *file, void *priv,
@@ -317,7 +319,7 @@ static int vidioc_try_fmt_vid_out_mplane(struct file *file, 
void *priv,
return -EINVAL;
}
 
-   return vidioc_try_fmt(f, fmt);
+   return vidioc_try_fmt(ctx, f, fmt);
 }
 
 static int vidioc_vdec_g_selection(struct file *file, void *priv,
@@ -445,7 +447,7 @@ static int vidioc_vdec_s_fmt(struct file *file, void *priv,
return -EINVAL;
 
q_data->fmt = fmt;
-   vidioc_try_fmt(f, q_data->fmt);
+   vidioc_try_fmt(ctx, f, q_data->fmt);
if (f->type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) {
q_data->sizeimage[0] = pix_mp->plane_fmt[0].sizeimage;
q_data->coded_width = pix_mp->width;
@@ -547,6 +549,9 @@ static int vidioc_enum_framesizes(struct file *file, void 
*priv,
fsize->stepwise.min_height,
fsize->stepwise.max_height,
fsize->stepwise.step_height);
+
+   ctx->max_width = fsize->stepwise.max_width;
+   ctx->max_height = fsize->stepwise.max_height;
return 0;
}
 
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h

[PATCH v1, 03/12] media: mtk-vcodec: get frame buffer size from scp

2021-12-14 Thread Yunfei Dong
From: Yunfei Dong 

Different capture buffer format has different buffer size, need to get
real buffer size according to buffer type from scp.

Signed-off-by: Yunfei Dong 
---
 .../platform/mtk-vcodec/mtk_vcodec_dec.c  |  2 +
 .../platform/mtk-vcodec/mtk_vcodec_drv.h  |  2 +
 .../media/platform/mtk-vcodec/vdec_ipi_msg.h  | 36 +
 .../media/platform/mtk-vcodec/vdec_vpu_if.c   | 51 +++
 .../media/platform/mtk-vcodec/vdec_vpu_if.h   | 15 ++
 5 files changed, 106 insertions(+)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
index 130ecef2e766..87891ebd7246 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
@@ -466,6 +466,8 @@ static int vidioc_vdec_s_fmt(struct file *file, void *priv,
}
ctx->state = MTK_STATE_INIT;
}
+   } else {
+   ctx->capture_fourcc = fmt->fourcc;
}
 
/*
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
index e9a31306b956..fc2c23deb825 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
@@ -277,6 +277,7 @@ struct vdec_pic_info {
  *  to be used with encoder and stateful decoder.
  * @is_flushing: set to true if flushing is in progress.
  * @current_codec: current set input codec, in V4L2 pixel format
+ * @capture_fourcc: capture queue type, in V4L2 pixel format
  *
  * @colorspace: enum v4l2_colorspace; supplemental to pixelformat
  * @ycbcr_enc: enum v4l2_ycbcr_encoding, Y'CbCr encoding
@@ -322,6 +323,7 @@ struct mtk_vcodec_ctx {
bool is_flushing;
 
u32 current_codec;
+   u32 capture_fourcc;
 
enum v4l2_colorspace colorspace;
enum v4l2_ycbcr_encoding ycbcr_enc;
diff --git a/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h 
b/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h
index 5daca8d52ebb..d00e555cf27a 100644
--- a/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h
+++ b/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h
@@ -20,6 +20,7 @@ enum vdec_ipi_msgid {
AP_IPIMSG_DEC_RESET = 0xA004,
AP_IPIMSG_DEC_CORE = 0xA005,
AP_IPIMSG_DEC_CORE_END = 0xA006,
+   AP_IPIMSG_DEC_GET_PARAM = 0xA007,
 
VPU_IPIMSG_DEC_INIT_ACK = 0xB000,
VPU_IPIMSG_DEC_START_ACK = 0xB001,
@@ -28,6 +29,7 @@ enum vdec_ipi_msgid {
VPU_IPIMSG_DEC_RESET_ACK = 0xB004,
VPU_IPIMSG_DEC_CORE_ACK = 0xB005,
VPU_IPIMSG_DEC_CORE_END_ACK = 0xB006,
+   VPU_IPIMSG_DEC_GET_PARAM_ACK = 0xB007,
 };
 
 /**
@@ -114,4 +116,38 @@ struct vdec_vpu_ipi_init_ack {
uint32_t inst_id;
 };
 
+/**
+ * struct vdec_ap_ipi_get_param - for AP_IPIMSG_SET_PARAM
+ * @msg_id : AP_IPIMSG_DEC_START
+ * @inst_id : instance ID. Used if the ABI version >= 2.
+ * @data   : picture information
+ * @param_type : get param type
+ * @codec_type : Codec fourcc
+ */
+struct vdec_ap_ipi_get_param {
+   uint32_t msg_id;
+   uint32_t inst_id;
+   uint32_t data[4];
+   uint32_t param_type;
+   uint32_t codec_type;
+};
+
+
+/**
+ * struct vdec_vpu_ipi_init_ack - for VPU_IPIMSG_DEC_INIT_ACK
+ * @msg_id : VPU_IPIMSG_DEC_INIT_ACK
+ * @status : VPU exeuction result
+ * @ap_inst_addr   : AP vcodec_vpu_inst instance address
+ * @data : picture information from SCP.
+ * @param_type : get param type
+ */
+struct vdec_vpu_ipi_get_param_ack {
+   uint32_t msg_id;
+   int32_t status;
+   uint64_t ap_inst_addr;
+   uint32_t data[4];
+   uint32_t param_type;
+   uint32_t reserved;
+};
+
 #endif
diff --git a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c 
b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
index 21f6d9c5a371..6f9bcc2b0bb9 100644
--- a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
+++ b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
@@ -54,6 +54,27 @@ static void handle_init_ack_msg(const struct 
vdec_vpu_ipi_init_ack *msg)
}
 }
 
+static void handle_get_param_msg_ack(
+   const struct vdec_vpu_ipi_get_param_ack *msg)
+{
+   struct vdec_vpu_inst *vpu = (struct vdec_vpu_inst *)
+   (unsigned long)msg->ap_inst_addr;
+
+   mtk_vcodec_debug(vpu, "+ ap_inst_addr = 0x%llx", msg->ap_inst_addr);
+
+   /* param_type is enum vdec_get_param_type */
+   switch(msg->param_type) {
+   case 2:
+   vpu->fb_sz[0] = msg->data[0];
+   vpu->fb_sz[1] = msg->data[1];
+   break;
+   default:
+   mtk_vcodec_err(vpu, "invalid get param type=%d", 
msg->param_type);
+   vpu->failure = 1;
+   break;
+   }
+}
+
 /*
  * vpu_dec_ipi_handler - Handler for VPU ipi message.
  *
@@ -89,6 +110,9 @@ static void vpu_dec_ipi_handler(void *data, unsigned int 

[PATCH v1, 02/12] media: mtk-vcodec: Using firmware type to separate different firmware architecture

2021-12-14 Thread Yunfei Dong
From: Yunfei Dong 

MT8173 platform use vpu firmware, mt8183/mt8192 will use scp
firmware instead, using chip name is not reasonable to separate
different firmware architecture. Using firmware type is much better.

Signed-off-by: Yunfei Dong 
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateful.c | 1 -
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c| 2 --
 drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h  | 2 --
 drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.c   | 6 ++
 drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.h   | 1 +
 drivers/media/platform/mtk-vcodec/vdec_vpu_if.c | 4 ++--
 6 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateful.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateful.c
index 04ca43c77e5f..7966c132be8f 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateful.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateful.c
@@ -613,7 +613,6 @@ static struct vb2_ops mtk_vdec_frame_vb2_ops = {
 };
 
 const struct mtk_vcodec_dec_pdata mtk_vdec_8173_pdata = {
-   .chip = MTK_MT8173,
.init_vdec_params = mtk_init_vdec_params,
.ctrls_setup = mtk_vcodec_dec_ctrls_setup,
.vdec_vb2_ops = _vdec_frame_vb2_ops,
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c
index 6c67b7f65f9c..1a4013f4fb83 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c
@@ -344,7 +344,6 @@ static struct vb2_ops mtk_vdec_request_vb2_ops = {
 };
 
 const struct mtk_vcodec_dec_pdata mtk_vdec_8183_pdata = {
-   .chip = MTK_MT8183,
.init_vdec_params = mtk_init_vdec_params,
.ctrls_setup = mtk_vcodec_dec_ctrls_setup,
.vdec_vb2_ops = _vdec_request_vb2_ops,
@@ -363,7 +362,6 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8183_pdata = {
 
 /* This platform data is used for one lat and one core architecture. */
 const struct mtk_vcodec_dec_pdata mtk_lat_sig_core_pdata = {
-   .chip = MTK_MT8192,
.init_vdec_params = mtk_init_vdec_params,
.ctrls_setup = mtk_vcodec_dec_ctrls_setup,
.vdec_vb2_ops = _vdec_request_vb2_ops,
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
index a558cc16026d..e9a31306b956 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
@@ -367,7 +367,6 @@ enum mtk_vdec_hw_arch {
  * @vdec_framesizes: supported video decoder frame sizes
  * @num_framesizes: count of video decoder frame sizes
  *
- * @chip: chip this decoder is compatible with
  * @hw_arch: hardware arch is used to separate pure_sin_core and lat_sin_core
  *
  * @is_subdev_supported: whether support parent-node architecture(subdev)
@@ -390,7 +389,6 @@ struct mtk_vcodec_dec_pdata {
const struct mtk_codec_framesizes *vdec_framesizes;
const int num_framesizes;
 
-   enum mtk_chip chip;
enum mtk_vdec_hw_arch hw_arch;
 
bool is_subdev_supported;
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.c
index 94b39ae5c2e1..556e54aadac9 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.c
@@ -65,3 +65,9 @@ int mtk_vcodec_fw_ipi_send(struct mtk_vcodec_fw *fw, int id, 
void *buf,
return fw->ops->ipi_send(fw, id, buf, len, wait);
 }
 EXPORT_SYMBOL_GPL(mtk_vcodec_fw_ipi_send);
+
+int mtk_vcodec_fw_get_type(struct mtk_vcodec_fw *fw)
+{
+   return fw->type;
+}
+EXPORT_SYMBOL_GPL(mtk_vcodec_fw_get_type);
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.h
index 539bb626772c..acd355961e3a 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_fw.h
@@ -39,5 +39,6 @@ int mtk_vcodec_fw_ipi_register(struct mtk_vcodec_fw *fw, int 
id,
   const char *name, void *priv);
 int mtk_vcodec_fw_ipi_send(struct mtk_vcodec_fw *fw, int id,
   void *buf, unsigned int len, unsigned int wait);
+int mtk_vcodec_fw_get_type(struct mtk_vcodec_fw *fw);
 
 #endif /* _MTK_VCODEC_FW_H_ */
diff --git a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c 
b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
index c84fac52fe26..21f6d9c5a371 100644
--- a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
+++ b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
@@ -33,8 +33,8 @@ static void handle_init_ack_msg(const struct 
vdec_vpu_ipi_init_ack *msg)
 */
vpu->inst_id = 0xdeadbeef;
 
-   /* Firmware version field does not exist on MT8173. */
-   if (vpu->ctx->dev->vdec_pdata->chip == MTK_MT8173)
+   

[PATCH v1, 00/12] media: mtk-vcodec: support for MT8192 h264 decoder

2021-12-14 Thread Yunfei Dong
This series adds support for mt8192 h264 decoder. Firstly, need to refactor
power/clk/irq interface for mt8192 is lat and core architecture. Secondly,
add new functions to get frame buffer size and resolution according to decoder
capability from scp side. Then add callback function to get/put capture buffer
in order to enable lat and core decoder in parallel. Then add to support MT21C
compressed mode and fix v4l2-compliance fail. Next, extract H264 request
api driver to let mt8183 and mt8192 use the common code, at last, add mt8192 
h264
slice api driver.

Patches 1 refactor power/clk/irq interface.
Patches 2~4 get frame buffer size and resolution according to decoder 
capability.
Patches 5~6 enable lat and core decode in parallel.
Patch 7~10 Add to support MT21C compressed mode and fix v4l2-compliance fail.
Patch 11~12 extract h264 driver and add mt8192 h264 slice api driver

Dependents on "Support multi hardware decode using of_platform_populate"[1].

This patches are the second part used to add mt8192 h264 decoder. And the base 
part is [1].

[1]https://patchwork.linuxtv.org/project/linux-media/cover/20211215061552.8523-1-yunfei.d...@mediatek.com/

Yunfei Dong (12):
  media: mtk-vcodec: Add vdec enable/disable hardware helpers
  media: mtk-vcodec: Using firmware type to separate different firmware
architecture
  media: mtk-vcodec: get frame buffer size from scp
  media: mtk-vcodec: Read max resolution from dec_capability
  media: mtk-vcodec: Call v4l2_m2m_set_dst_buffered() set capture buffer
buffered
  media: mtk-vcodec: Refactor get and put capture buffer flow
  media: mtk-vcodec: Refactor supported vdec formats and framesizes
  media: mtk-vcodec: Add format to support MT21C
  media: mtk-vcodec: disable vp8 4K capability
  media: mtk-vcodec: Fix v4l2-compliance fail
  media: mtk-vcodec: Extract H264 common code
  media: mtk-vcodec: Add h264 slice api driver for mt8192

 drivers/media/platform/mtk-vcodec/Makefile|   2 +
 .../platform/mtk-vcodec/mtk_vcodec_dec.c  |  49 +-
 .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c  |   5 -
 .../platform/mtk-vcodec/mtk_vcodec_dec_pm.c   | 162 +++--
 .../platform/mtk-vcodec/mtk_vcodec_dec_pm.h   |   6 +-
 .../mtk-vcodec/mtk_vcodec_dec_stateful.c  |  14 +-
 .../mtk-vcodec/mtk_vcodec_dec_stateless.c | 245 +--
 .../platform/mtk-vcodec/mtk_vcodec_drv.h  |  27 +-
 .../media/platform/mtk-vcodec/mtk_vcodec_fw.c |   6 +
 .../media/platform/mtk-vcodec/mtk_vcodec_fw.h |   1 +
 .../mtk-vcodec/vdec/vdec_h264_req_common.c| 303 +
 .../mtk-vcodec/vdec/vdec_h264_req_common.h| 247 +++
 .../mtk-vcodec/vdec/vdec_h264_req_if.c| 402 +---
 .../mtk-vcodec/vdec/vdec_h264_req_lat_if.c| 620 ++
 .../media/platform/mtk-vcodec/vdec_drv_if.c   |  28 +-
 .../media/platform/mtk-vcodec/vdec_drv_if.h   |   1 +
 .../media/platform/mtk-vcodec/vdec_ipi_msg.h  |  36 +
 .../platform/mtk-vcodec/vdec_msg_queue.c  |   2 +
 .../media/platform/mtk-vcodec/vdec_vpu_if.c   |  55 +-
 .../media/platform/mtk-vcodec/vdec_vpu_if.h   |  15 +
 include/linux/remoteproc/mtk_scp.h|   2 +
 21 files changed, 1672 insertions(+), 556 deletions(-)
 create mode 100644 
drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_common.c
 create mode 100644 
drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_common.h
 create mode 100644 
drivers/media/platform/mtk-vcodec/vdec/vdec_h264_req_lat_if.c

-- 
2.25.1



[PATCH v1, 01/12] media: mtk-vcodec: Add vdec enable/disable hardware helpers

2021-12-14 Thread Yunfei Dong
From: Yunfei Dong 

Lock, power and clock are highly coupled operations. Adds vdec
enable/disable hardware helpers and uses them.

Signed-off-by: Yunfei Dong 
---
 .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c  |   5 -
 .../platform/mtk-vcodec/mtk_vcodec_dec_pm.c   | 162 +++---
 .../platform/mtk-vcodec/mtk_vcodec_dec_pm.h   |   6 +-
 .../media/platform/mtk-vcodec/vdec_drv_if.c   |  20 +--
 .../platform/mtk-vcodec/vdec_msg_queue.c  |   2 +
 5 files changed, 110 insertions(+), 85 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
index 3f8f3309cf9d..3cbdbf1ad3e5 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
@@ -223,9 +223,6 @@ static int fops_vcodec_open(struct file *file)
mtk_vcodec_dec_set_default_params(ctx);
 
if (v4l2_fh_is_singular(>fh)) {
-   ret = mtk_vcodec_dec_pw_on(dev, MTK_VDEC_LAT0);
-   if (ret < 0)
-   goto err_load_fw;
/*
 * Does nothing if firmware was already loaded.
 */
@@ -282,8 +279,6 @@ static int fops_vcodec_release(struct file *file)
v4l2_m2m_ctx_release(ctx->m2m_ctx);
mtk_vcodec_dec_release(ctx);
 
-   if (v4l2_fh_is_singular(>fh))
-   mtk_vcodec_dec_pw_off(dev, MTK_VDEC_LAT0);
v4l2_fh_del(>fh);
v4l2_fh_exit(>fh);
v4l2_ctrl_handler_free(>ctrl_hdl);
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
index b9f5ef979c69..aa24e073e3b2 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
@@ -80,74 +80,31 @@ int mtk_vcodec_init_dec_clk(struct platform_device *pdev,
 }
 EXPORT_SYMBOL_GPL(mtk_vcodec_init_dec_clk);
 
-int mtk_vcodec_dec_pw_on(struct mtk_vcodec_dev *vdec_dev, int hw_idx)
+static int mtk_vcodec_dec_pw_on(struct mtk_vcodec_pm *pm)
 {
-   struct mtk_vdec_hw_dev *subdev_dev;
-   struct mtk_vcodec_pm *pm;
int ret;
 
-   if (vdec_dev->vdec_pdata->is_subdev_supported) {
-   subdev_dev = mtk_vcodec_get_hw_dev(vdec_dev, hw_idx);
-   if (!subdev_dev) {
-   mtk_v4l2_err("Failed to get hw dev\n");
-   return -EINVAL;
-   }
-   pm = _dev->pm;
-   } else {
-   pm = _dev->pm;
-   }
-
ret = pm_runtime_resume_and_get(pm->dev);
if (ret)
mtk_v4l2_err("pm_runtime_resume_and_get fail %d", ret);
 
return ret;
 }
-EXPORT_SYMBOL_GPL(mtk_vcodec_dec_pw_on);
 
-void mtk_vcodec_dec_pw_off(struct mtk_vcodec_dev *vdec_dev, int hw_idx)
+static void mtk_vcodec_dec_pw_off(struct mtk_vcodec_pm *pm)
 {
-   struct mtk_vdec_hw_dev *subdev_dev;
-   struct mtk_vcodec_pm *pm;
int ret;
 
-   if (vdec_dev->vdec_pdata->is_subdev_supported) {
-   subdev_dev = mtk_vcodec_get_hw_dev(vdec_dev, hw_idx);
-   if (!subdev_dev) {
-   mtk_v4l2_err("Failed to get hw dev\n");
-   return;
-   }
-   pm = _dev->pm;
-   } else {
-   pm = _dev->pm;
-   }
-
ret = pm_runtime_put_sync(pm->dev);
if (ret)
mtk_v4l2_err("pm_runtime_put_sync fail %d", ret);
 }
-EXPORT_SYMBOL_GPL(mtk_vcodec_dec_pw_off);
 
-void mtk_vcodec_dec_clock_on(struct mtk_vcodec_dev *vdec_dev, int hw_idx)
+static void mtk_vcodec_dec_clock_on(struct mtk_vcodec_pm *pm)
 {
-   struct mtk_vdec_hw_dev *subdev_dev;
-   struct mtk_vcodec_pm *pm;
struct mtk_vcodec_clk *dec_clk;
int ret, i;
 
-   if (vdec_dev->vdec_pdata->is_subdev_supported) {
-   subdev_dev = mtk_vcodec_get_hw_dev(vdec_dev, hw_idx);
-   if (!subdev_dev) {
-   mtk_v4l2_err("Failed to get hw dev\n");
-   return;
-   }
-   pm = _dev->pm;
-   enable_irq(subdev_dev->dec_irq);
-   } else {
-   pm = _dev->pm;
-   enable_irq(vdec_dev->dec_irq);
-   }
-
dec_clk = >vdec_clk;
for (i = 0; i < dec_clk->clk_num; i++) {
ret = clk_prepare_enable(dec_clk->clk_info[i].vcodec_clk);
@@ -169,31 +126,112 @@ void mtk_vcodec_dec_clock_on(struct mtk_vcodec_dev 
*vdec_dev, int hw_idx)
for (i -= 1; i >= 0; i--)
clk_disable_unprepare(dec_clk->clk_info[i].vcodec_clk);
 }
-EXPORT_SYMBOL_GPL(mtk_vcodec_dec_clock_on);
 
-void mtk_vcodec_dec_clock_off(struct mtk_vcodec_dev *vdec_dev, int hw_idx)
+static void mtk_vcodec_dec_clock_off(struct mtk_vcodec_pm *pm)
 {
-   struct mtk_vdec_hw_dev *subdev_dev;
-   struct mtk_vcodec_pm *pm;
struct mtk_vcodec_clk *dec_clk;
int i;
 
+   dec_clk = 

[PATCH v3] drm/amdgpu: introduce new amdgpu_fence object to indicate the job embedded fence

2021-12-14 Thread Huang Rui
The job embedded fence donesn't initialize the flags at
dma_fence_init(). Then we will go a wrong way in
amdgpu_fence_get_timeline_name callback and trigger a null pointer panic
once we enabled the trace event here. So introduce new amdgpu_fence
object to indicate the job embedded fence.

[  156.131790] BUG: kernel NULL pointer dereference, address: 02a0
[  156.131804] #PF: supervisor read access in kernel mode
[  156.131811] #PF: error_code(0x) - not-present page
[  156.131817] PGD 0 P4D 0
[  156.131824] Oops:  [#1] PREEMPT SMP PTI
[  156.131832] CPU: 6 PID: 1404 Comm: sdma0 Tainted: G   OE 
5.16.0-rc1-custom #1
[  156.131842] Hardware name: Gigabyte Technology Co., Ltd. 
Z170XP-SLI/Z170XP-SLI-CF, BIOS F20 11/04/2016
[  156.131848] RIP: 0010:strlen+0x0/0x20
[  156.131859] Code: 89 c0 c3 0f 1f 80 00 00 00 00 48 01 fe eb 0f 0f b6 07 38 
d0 74 10 48 83 c7 01 84 c0 74 05 48 39 f7 75 ec 31 c0 c3 48 89 f8 c3 <80> 3f 00 
74 10 48 89 f8 48 83 c0 01 80 38 00 75 f7 48 29 f8 c3 31
[  156.131872] RSP: 0018:9bd0018dbcf8 EFLAGS: 00010206
[  156.131880] RAX: 02a0 RBX: 8d0305ef01b0 RCX: 000b
[  156.131888] RDX: 8d03772ab924 RSI: 8d0305ef01b0 RDI: 02a0
[  156.131895] RBP: 9bd0018dbd60 R08: 8d03002094d0 R09: 
[  156.131901] R10: 005e R11: 0065 R12: 8d03002094d0
[  156.131907] R13: 001f R14: 00070018 R15: 0007
[  156.131914] FS:  () GS:8d062ed8() 
knlGS:
[  156.131923] CS:  0010 DS:  ES:  CR0: 80050033
[  156.131929] CR2: 02a0 CR3: 1120a005 CR4: 003706e0
[  156.131937] DR0:  DR1:  DR2: 
[  156.131942] DR3:  DR6: fffe0ff0 DR7: 0400
[  156.131949] Call Trace:
[  156.131953]  
[  156.131957]  ? trace_event_raw_event_dma_fence+0xcc/0x200
[  156.131973]  ? ring_buffer_unlock_commit+0x23/0x130
[  156.131982]  dma_fence_init+0x92/0xb0
[  156.131993]  amdgpu_fence_emit+0x10d/0x2b0 [amdgpu]
[  156.132302]  amdgpu_ib_schedule+0x2f9/0x580 [amdgpu]
[  156.132586]  amdgpu_job_run+0xed/0x220 [amdgpu]

Signed-off-by: Huang Rui 
---

V1 -> V2: add another amdgpu_fence_ops which is for job-embedded fence.
V2 -> V3: use amdgpu_fence_driver_clear_job_fences abstract the job fence
clearing operation.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  11 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c  | 126 ++---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h   |   4 +-
 3 files changed, 90 insertions(+), 51 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 5625f7736e37..fecf7a09e5a2 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -4456,7 +4456,7 @@ int amdgpu_device_mode1_reset(struct amdgpu_device *adev)
 int amdgpu_device_pre_asic_reset(struct amdgpu_device *adev,
 struct amdgpu_reset_context *reset_context)
 {
-   int i, j, r = 0;
+   int i, r = 0;
struct amdgpu_job *job = NULL;
bool need_full_reset =
test_bit(AMDGPU_NEED_FULL_RESET, _context->flags);
@@ -4478,15 +4478,8 @@ int amdgpu_device_pre_asic_reset(struct amdgpu_device 
*adev,
 
/*clear job fence from fence drv to avoid force_completion
 *leave NULL and vm flush fence in fence drv */
-   for (j = 0; j <= ring->fence_drv.num_fences_mask; j++) {
-   struct dma_fence *old, **ptr;
+   amdgpu_fence_driver_clear_job_fences(ring);
 
-   ptr = >fence_drv.fences[j];
-   old = rcu_dereference_protected(*ptr, 1);
-   if (old && test_bit(AMDGPU_FENCE_FLAG_EMBED_IN_JOB_BIT, 
>flags)) {
-   RCU_INIT_POINTER(*ptr, NULL);
-   }
-   }
/* after all hw jobs are reset, hw fence is meaningless, so 
force_completion */
amdgpu_fence_driver_force_completion(ring);
}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
index 3b7e86ea7167..db41d16838b9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c
@@ -77,11 +77,13 @@ void amdgpu_fence_slab_fini(void)
  * Cast helper
  */
 static const struct dma_fence_ops amdgpu_fence_ops;
+static const struct dma_fence_ops amdgpu_job_fence_ops;
 static inline struct amdgpu_fence *to_amdgpu_fence(struct dma_fence *f)
 {
struct amdgpu_fence *__f = container_of(f, struct amdgpu_fence, base);
 
-   if (__f->base.ops == _fence_ops)
+   if (__f->base.ops == _fence_ops ||
+   __f->base.ops == _job_fence_ops)
return __f;
 
return NULL;
@@ -158,19 

Re: [PATCH v3 0/7] drm: exynos: dsi: Convert drm bridge

2021-12-14 Thread Jagan Teki
On Wed, Dec 15, 2021 at 11:39 AM Marek Szyprowski
 wrote:
>
> Hi Jagan,
>
> On 14.12.2021 11:47, Jagan Teki wrote:
> > On Mon, Dec 13, 2021 at 7:42 PM Marek Szyprowski
> >  wrote:
> >> On 13.12.2021 14:56, Jagan Teki wrote:
> >>> On Mon, Dec 13, 2021 at 6:51 PM Marek Szyprowski
> >>>  wrote:
>  On 13.12.2021 13:31, Jagan Teki wrote:
> > On Mon, Dec 13, 2021 at 5:42 PM Marek Szyprowski
> >  wrote:
> >> On 13.12.2021 13:08, Jagan Teki wrote:
> >>> On Mon, Dec 13, 2021 at 5:34 PM Marek Szyprowski
> >>>  wrote:
>  On 12.12.2021 19:14, Jagan Teki wrote:
> > Updated series about drm bridge conversion of exynos dsi.
> >
> > Patch 1: panel checker
> >
> > Patch 2: panel_bridge API
> >
> > Patch 3: Bridge conversion
> >
> > Patch 4: pree_enable, post_disable
> >
> > Patch 5: Atomic functions
> >
> > Patch 6: atomic_set
> >
> > Patch 7: DSI init in enable
> >
> > [1] 
> > https://patchwork.kernel.org/project/dri-devel/cover/20211210191922.2367979-1-ja...@amarulasolutions.com/
> >
> > Any inputs?
>  I've checked this patchset on Exynos based Trats2 board (the one with
>  simplest display pipeline: Exynos FIMD -> Exynos DSI -> s6e8aa0 DSI
>  panel). DRM stops working after the 2nd patch ("[PATCH v3 2/7] drm:
>  exynos: dsi: Use drm panel_bridge API"):
> 
>  > [...]
> >>> Thanks for testing it.
> >>>
> >>> Can you test it on the downstream bridge, tc358764 and post the result?
> >> There were 2 logs in my reply. One from trats2 board (just dsi panel)
> >> and one from arndale (tc bridge + simple panel).
> > Okay. Got it.
> >
> > Can you test this tc358764 panel_bridge patch on linux-next? don't
> > apply this series, apply only below patch and test.
> >
> Yes, sure. Sadly, it also breaks display operation:
>
> OF: graph: no port node found in /soc/hdmi@1453
> [drm] Exynos DRM: using 1440.fimd device for DMA mapping operations
> exynos-drm exynos-drm: bound 1440.fimd (ops fimd_component_ops)
> exynos-drm exynos-drm: bound 1445.mixer (ops mixer_component_ops)
> OF: graph: no port node found in /soc/dsi@1450
> exynos-drm exynos-drm: bound 1450.dsi (ops exynos_dsi_component_ops)
> exynos-drm exynos-drm: bound 1453.hdmi (ops hdmi_component_ops)
> exynos-drm exynos-drm: [drm] Cannot find any crtc or sizes
> exynos-drm exynos-drm: [drm] Cannot find any crtc or sizes
> [drm] Initialized exynos 1.1.0 20180330 for exynos-drm on minor 0
> panfrost 1180.gpu: clock rate = 53300
> panfrost 1180.gpu: mali-t600 id 0x600 major 0x0 minor 0x0 status 0x1
> panfrost 1180.gpu: features: ,10206000, issues:
> ,31b4dfff
> panfrost 1180.gpu: Features: L2:0x07110206 Shader:0x
> Tiler:0x0809 Mem:0x1 MMU:0x2830 AS:0xf JS:0x7
> panfrost 1180.gpu: shader_present=0xf l2_present=0x1
> [drm] Initialized panfrost 1.2.0 20180908 for 1180.gpu on minor 1
> [ cut here ]
> WARNING: CPU: 1 PID: 23 at drivers/gpu/drm/drm_atomic_state_helper.c:494
> drm_atomic_helper_connector_duplicate_state+0x60/0x68
> Modules linked in:
> CPU: 1 PID: 23 Comm: kworker/1:1 Not tainted
> 5.16.0-rc5-next-20211213-1-gac4117943791 #11072
> Hardware name: Samsung Exynos (Flattened Device Tree)
> Workqueue: events output_poll_execute
> [] (unwind_backtrace) from [] (show_stack+0x10/0x14)
> [] (show_stack) from [] (dump_stack_lvl+0x58/0x70)
> [] (dump_stack_lvl) from [] (__warn+0x228/0x22c)
> [] (__warn) from [] (warn_slowpath_fmt+0xac/0xb4)
> [] (warn_slowpath_fmt) from []
> (drm_atomic_helper_connector_duplicate_state+0x60/0x68)
> [] (drm_atomic_helper_connector_duplicate_state) from
> [] (drm_atomic_get_connector_state+0xd8/0x190)
> [] (drm_atomic_get_connector_state) from []
> (__drm_atomic_helper_set_config+0x2a0/0x368)
> [] (__drm_atomic_helper_set_config) from []
> (drm_client_modeset_commit_atomic+0x178/0x27c)
> [] (drm_client_modeset_commit_atomic) from []
> (drm_client_modeset_commit_locked+0x48/0x1d0)
> [] (drm_client_modeset_commit_locked) from []
> (drm_client_modeset_commit+0x24/0x40)
> [] (drm_client_modeset_commit) from []
> (__drm_fb_helper_restore_fbdev_mode_unlocked+0x64/0xc8)
> [] (__drm_fb_helper_restore_fbdev_mode_unlocked) from
> [] (drm_fb_helper_set_par+0x38/0x64)
> [] (drm_fb_helper_set_par) from []
> (drm_fb_helper_hotplug_event.part.5+0xa8/0xc0)
> [] (drm_fb_helper_hotplug_event.part.5) from []
> (drm_kms_helper_hotplug_event+0x24/0x30)
> [] (drm_kms_helper_hotplug_event) from []
> (output_poll_execute+0x1ec/0x204)
> [] (output_poll_execute) from []
> (process_one_work+0x2c8/0x7ec)
> [] (process_one_work) from [] (worker_thread+0x50/0x584)
> [] (worker_thread) from [] (kthread+0x13c/0x19c)
> [] (kthread) from [] (ret_from_fork+0x14/0x2c)
> Exception stack(0xc1d35fb0 to 0xc1d35ff8)
> 5fa0:   

[PATCH v14, 18/19] media: mtk-vcodec: Remove mtk_vcodec_release_dec_pm

2021-12-14 Thread Yunfei Dong
There are only two lines in mtk_vcodec_release_dec_pm, using
pm_runtime_disable and put_device instead directly.

Move pm_runtime_enable outside mtk_vcodec_init_dec_pm to symmetry with
pm_runtime_disable, after that, rename mtk_vcodec_init_dec_pm to *_clk since
it only has clock operations now.

Reviewed-by: AngeloGioacchino Del Regno 

Signed-off-by: Yunfei Dong 
Co-developed-by: Yong Wu 
---
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c   | 10 +++---
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_hw.c|  7 +--
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c| 12 ++--
 .../media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h|  3 +--
 4 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
index 41ae38c56871..9105d66ea05c 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -131,12 +132,13 @@ static int mtk_vcodec_init_dec_resources(struct 
mtk_vcodec_dev *dev)
return ret;
}
 
-   ret = mtk_vcodec_init_dec_pm(pdev, >pm);
+   ret = mtk_vcodec_init_dec_clk(pdev, >pm);
if (ret < 0) {
dev_err(>dev, "failed to get mt vcodec clock source");
return ret;
}
 
+   pm_runtime_enable(>dev);
return 0;
 }
 
@@ -446,7 +448,8 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
if (IS_VDEC_LAT_ARCH(dev->vdec_pdata->hw_arch))
destroy_workqueue(dev->core_workqueue);
 err_res:
-   mtk_vcodec_release_dec_pm(>pm);
+   pm_runtime_disable(dev->pm.dev);
+   put_device(dev->pm.larbvdec);
 err_dec_pm:
mtk_vcodec_fw_release(dev->fw_handler);
return ret;
@@ -490,7 +493,8 @@ static int mtk_vcodec_dec_remove(struct platform_device 
*pdev)
video_unregister_device(dev->vfd_dec);
 
v4l2_device_unregister(>v4l2_dev);
-   mtk_vcodec_release_dec_pm(>pm);
+   pm_runtime_disable(dev->pm.dev);
+   put_device(dev->pm.larbvdec);
mtk_vcodec_fw_release(dev->fw_handler);
return 0;
 }
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.c
index 643cee119b60..8e1247d65a93 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "mtk_vcodec_drv.h"
@@ -140,9 +141,10 @@ static int mtk_vdec_hw_probe(struct platform_device *pdev)
return -ENOMEM;
 
subdev_dev->plat_dev = pdev;
-   ret = mtk_vcodec_init_dec_pm(pdev, _dev->pm);
+   ret = mtk_vcodec_init_dec_clk(pdev, _dev->pm);
if (ret)
return ret;
+   pm_runtime_enable(>dev);
 
of_id = of_match_device(mtk_vdec_hw_match, dev);
if (!of_id) {
@@ -181,7 +183,8 @@ static int mtk_vdec_hw_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, subdev_dev);
return 0;
 err:
-   mtk_vcodec_release_dec_pm(_dev->pm);
+   pm_runtime_disable(subdev_dev->pm.dev);
+   put_device(subdev_dev->pm.larbvdec);
return ret;
 }
 
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
index 4cf03d38d141..b9f5ef979c69 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
@@ -15,7 +15,7 @@
 #include "mtk_vcodec_dec_pm.h"
 #include "mtk_vcodec_util.h"
 
-int mtk_vcodec_init_dec_pm(struct platform_device *pdev,
+int mtk_vcodec_init_dec_clk(struct platform_device *pdev,
struct mtk_vcodec_pm *pm)
 {
struct device_node *node;
@@ -73,20 +73,12 @@ int mtk_vcodec_init_dec_pm(struct platform_device *pdev,
}
}
 
-   pm_runtime_enable(>dev);
return 0;
 put_device:
put_device(pm->larbvdec);
return ret;
 }
-EXPORT_SYMBOL_GPL(mtk_vcodec_init_dec_pm);
-
-void mtk_vcodec_release_dec_pm(struct mtk_vcodec_pm *pm)
-{
-   pm_runtime_disable(pm->dev);
-   put_device(pm->larbvdec);
-}
-EXPORT_SYMBOL_GPL(mtk_vcodec_release_dec_pm);
+EXPORT_SYMBOL_GPL(mtk_vcodec_init_dec_clk);
 
 int mtk_vcodec_dec_pw_on(struct mtk_vcodec_dev *vdec_dev, int hw_idx)
 {
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h
index 6ae29fea4e7f..c4121df9764f 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h
@@ -9,9 +9,8 @@
 
 #include "mtk_vcodec_drv.h"
 
-int mtk_vcodec_init_dec_pm(struct platform_device *pdev,
+int mtk_vcodec_init_dec_clk(struct platform_device *pdev,
 

[PATCH v14, 19/19] media: mtk-vcodec: Remove mtk_vcodec_release_enc_pm

2021-12-14 Thread Yunfei Dong
There are only two lines in mtk_vcodec_release_enc_pm, using
pm_runtime_disable and put_device instead directly.

Move pm_runtime_enable outside mtk_vcodec_release_enc_pm to symmetry with
pm_runtime_disable, after that, rename mtk_vcodec_init_enc_pm to *_clk since
it only has clock operations now.

Reviewed-by: AngeloGioacchino Del Regno 

Signed-off-by: Yunfei Dong 
Co-developed-by: Yong Wu 
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c | 9 ++---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c  | 9 +
 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.h  | 3 +--
 3 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
index 0f326d82dea0..7816efb90cbe 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -260,7 +261,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
return PTR_ERR(dev->fw_handler);
 
dev->venc_pdata = of_device_get_match_data(>dev);
-   ret = mtk_vcodec_init_enc_pm(dev);
+   ret = mtk_vcodec_init_enc_clk(dev);
if (ret < 0) {
dev_err(>dev, "Failed to get mtk vcodec clock source!");
goto err_enc_pm;
@@ -372,7 +373,8 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
 err_enc_alloc:
v4l2_device_unregister(>v4l2_dev);
 err_res:
-   mtk_vcodec_release_enc_pm(dev);
+   pm_runtime_disable(dev->pm.dev);
+   put_device(dev->pm.larbvenc);
 err_enc_pm:
mtk_vcodec_fw_release(dev->fw_handler);
return ret;
@@ -462,7 +464,8 @@ static int mtk_vcodec_enc_remove(struct platform_device 
*pdev)
video_unregister_device(dev->vfd_enc);
 
v4l2_device_unregister(>v4l2_dev);
-   mtk_vcodec_release_enc_pm(dev);
+   pm_runtime_disable(dev->pm.dev);
+   put_device(dev->pm.larbvenc);
mtk_vcodec_fw_release(dev->fw_handler);
return 0;
 }
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c
index 0c8c8f86788c..0825c6ec4eb7 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.c
@@ -13,7 +13,7 @@
 #include "mtk_vcodec_enc_pm.h"
 #include "mtk_vcodec_util.h"
 
-int mtk_vcodec_init_enc_pm(struct mtk_vcodec_dev *mtkdev)
+int mtk_vcodec_init_enc_clk(struct mtk_vcodec_dev *mtkdev)
 {
struct device_node *node;
struct platform_device *pdev;
@@ -86,13 +86,6 @@ int mtk_vcodec_init_enc_pm(struct mtk_vcodec_dev *mtkdev)
return ret;
 }
 
-void mtk_vcodec_release_enc_pm(struct mtk_vcodec_dev *mtkdev)
-{
-   pm_runtime_disable(mtkdev->pm.dev);
-   put_device(mtkdev->pm.larbvenc);
-}
-
-
 void mtk_vcodec_enc_clock_on(struct mtk_vcodec_pm *pm)
 {
struct mtk_vcodec_clk *enc_clk = >venc_clk;
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.h
index b7ecdfd74823..bc455cefc0cd 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_pm.h
@@ -9,8 +9,7 @@
 
 #include "mtk_vcodec_drv.h"
 
-int mtk_vcodec_init_enc_pm(struct mtk_vcodec_dev *dev);
-void mtk_vcodec_release_enc_pm(struct mtk_vcodec_dev *dev);
+int mtk_vcodec_init_enc_clk(struct mtk_vcodec_dev *dev);
 
 void mtk_vcodec_enc_clock_on(struct mtk_vcodec_pm *pm);
 void mtk_vcodec_enc_clock_off(struct mtk_vcodec_pm *pm);
-- 
2.25.1



[PATCH v14, 13/19] media: mtk-vcodec: Add work queue for core hardware decode

2021-12-14 Thread Yunfei Dong
Add work queue to process core hardware information.
First, get lat_buf from message queue, then call core
hardware of each codec(H264/VP9/AV1) to decode, finally
puts lat_buf back to the message.

Reviewed-by: Steve Cho 
Signed-off-by: Yunfei Dong 
---
 .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c  | 16 +++-
 .../platform/mtk-vcodec/mtk_vcodec_drv.h  |  3 ++
 .../platform/mtk-vcodec/vdec_msg_queue.c  | 41 ---
 .../platform/mtk-vcodec/vdec_msg_queue.h  |  8 ++--
 4 files changed, 57 insertions(+), 11 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
index 63b8a2341835..a019f3fed0ff 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
@@ -314,6 +314,17 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
goto err_dec_pm;
}
 
+   if (IS_VDEC_LAT_ARCH(dev->vdec_pdata->hw_arch)) {
+   vdec_msg_queue_init_ctx(>msg_queue_core_ctx, 
MTK_VDEC_CORE);
+   dev->core_workqueue = alloc_ordered_workqueue("core-decoder",
+   WQ_MEM_RECLAIM | WQ_FREEZABLE);
+   if (!dev->core_workqueue) {
+   mtk_v4l2_err("Failed to create core workqueue");
+   ret = -EINVAL;
+   goto err_res;
+   }
+   }
+
for (i = 0; i < MTK_VDEC_HW_MAX; i++)
mutex_init(>dec_mutex[i]);
spin_lock_init(>irqlock);
@@ -324,7 +335,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
ret = v4l2_device_register(>dev, >v4l2_dev);
if (ret) {
mtk_v4l2_err("v4l2_device_register err=%d", ret);
-   goto err_res;
+   goto err_core_workq;
}
 
init_waitqueue_head(>queue);
@@ -423,6 +434,9 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
video_unregister_device(vfd_dec);
 err_dec_alloc:
v4l2_device_unregister(>v4l2_dev);
+err_core_workq:
+   if (IS_VDEC_LAT_ARCH(dev->vdec_pdata->hw_arch))
+   destroy_workqueue(dev->core_workqueue);
 err_res:
mtk_vcodec_release_dec_pm(>pm);
 err_dec_pm:
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
index 517515ee9ac4..3fc747cea5c9 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
@@ -27,6 +27,7 @@
 #define MTK_VCODEC_MAX_PLANES  3
 #define MTK_V4L2_BENCHMARK 0
 #define WAIT_INTR_TIMEOUT_MS   1000
+#define IS_VDEC_LAT_ARCH(hw_arch) ((hw_arch) >= MTK_VDEC_LAT_SINGLE_CORE)
 
 /*
  * enum mtk_hw_reg_idx - MTK hw register base index
@@ -464,6 +465,7 @@ struct mtk_vcodec_enc_pdata {
  * @dec_capability: used to identify decode capability, ex: 4k
  * @enc_capability: used to identify encode capability
  *
+ * @core_workqueue: queue used for core hardware decode
  * @msg_queue_core_ctx: msg queue context used for core workqueue
  *
  * @subdev_dev: subdev hardware device
@@ -507,6 +509,7 @@ struct mtk_vcodec_dev {
unsigned int dec_capability;
unsigned int enc_capability;
 
+   struct workqueue_struct *core_workqueue;
struct vdec_msg_queue_ctx msg_queue_core_ctx;
 
void *subdev_dev[MTK_VDEC_HW_MAX];
diff --git a/drivers/media/platform/mtk-vcodec/vdec_msg_queue.c 
b/drivers/media/platform/mtk-vcodec/vdec_msg_queue.c
index 913aefa67618..24f1d03df9f1 100644
--- a/drivers/media/platform/mtk-vcodec/vdec_msg_queue.c
+++ b/drivers/media/platform/mtk-vcodec/vdec_msg_queue.c
@@ -68,6 +68,9 @@ int vdec_msg_queue_qbuf(struct vdec_msg_queue_ctx *msg_ctx, 
struct vdec_lat_buf
 
if (msg_ctx->hardware_index != MTK_VDEC_CORE)
wake_up_all(_ctx->ready_to_use);
+   else
+   queue_work(buf->ctx->dev->core_workqueue,
+   >ctx->msg_queue.core_work);
 
mtk_v4l2_debug(3, "enqueue buf type: %d addr: 0x%p num: %d",
msg_ctx->hardware_index, buf, msg_ctx->ready_num);
@@ -169,8 +172,7 @@ bool vdec_msg_queue_wait_lat_buf_full(struct vdec_msg_queue 
*msg_queue)
return false;
 }
 
-void vdec_msg_queue_deinit(
-   struct vdec_msg_queue *msg_queue,
+void vdec_msg_queue_deinit(struct vdec_msg_queue *msg_queue,
struct mtk_vcodec_ctx *ctx)
 {
struct vdec_lat_buf *lat_buf;
@@ -196,10 +198,36 @@ void vdec_msg_queue_deinit(
}
 }
 
-int vdec_msg_queue_init(
-   struct vdec_msg_queue *msg_queue,
-   struct mtk_vcodec_ctx *ctx,
-   core_decode_cb_t core_decode,
+static void vdec_msg_queue_core_work(struct work_struct *work)
+{
+   struct vdec_msg_queue *msg_queue =
+   container_of(work, struct vdec_msg_queue, core_work);
+   struct mtk_vcodec_ctx *ctx =
+   container_of(msg_queue, struct mtk_vcodec_ctx, msg_queue);
+   

[PATCH v14, 17/19] media: mtk-vcodec: Use codec type to separate different hardware

2021-12-14 Thread Yunfei Dong
There is just one core thread, in order to separate different
hardware, using codec type to separeate it in scp driver.

Signed-off-by: Yunfei Dong 
Reviewed-by: AngeloGioacchino Del Regno 

---
 .../media/platform/mtk-vcodec/vdec_ipi_msg.h  | 12 ---
 .../media/platform/mtk-vcodec/vdec_vpu_if.c   | 34 ---
 .../media/platform/mtk-vcodec/vdec_vpu_if.h   |  4 +++
 3 files changed, 41 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h 
b/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h
index 9d8079c4f976..5daca8d52ebb 100644
--- a/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h
+++ b/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h
@@ -35,6 +35,8 @@ enum vdec_ipi_msgid {
  * @msg_id : vdec_ipi_msgid
  * @vpu_inst_addr : VPU decoder instance address. Used if ABI version < 2.
  * @inst_id : instance ID. Used if the ABI version >= 2.
+ * @codec_type : codec fourcc
+ * @reserved   : reserved param
  */
 struct vdec_ap_ipi_cmd {
uint32_t msg_id;
@@ -42,6 +44,8 @@ struct vdec_ap_ipi_cmd {
uint32_t vpu_inst_addr;
uint32_t inst_id;
};
+   uint32_t codec_type;
+   uint32_t reserved;
 };
 
 /**
@@ -59,12 +63,12 @@ struct vdec_vpu_ipi_ack {
 /**
  * struct vdec_ap_ipi_init - for AP_IPIMSG_DEC_INIT
  * @msg_id : AP_IPIMSG_DEC_INIT
- * @reserved   : Reserved field
+ * @codec_type : codec fourcc
  * @ap_inst_addr   : AP video decoder instance address
  */
 struct vdec_ap_ipi_init {
uint32_t msg_id;
-   uint32_t reserved;
+   uint32_t codec_type;
uint64_t ap_inst_addr;
 };
 
@@ -77,7 +81,7 @@ struct vdec_ap_ipi_init {
  * H264 decoder [0]:buf_sz [1]:nal_start
  * VP8 decoder  [0]:width/height
  * VP9 decoder  [0]:profile, [1][2] width/height
- * @reserved   : Reserved field
+ * @codec_type : codec fourcc
  */
 struct vdec_ap_ipi_dec_start {
uint32_t msg_id;
@@ -86,7 +90,7 @@ struct vdec_ap_ipi_dec_start {
uint32_t inst_id;
};
uint32_t data[3];
-   uint32_t reserved;
+   uint32_t codec_type;
 };
 
 /**
diff --git a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c 
b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
index bfd8e87dceff..c84fac52fe26 100644
--- a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
+++ b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
@@ -100,18 +100,29 @@ static void vpu_dec_ipi_handler(void *data, unsigned int 
len, void *priv)
 
 static int vcodec_vpu_send_msg(struct vdec_vpu_inst *vpu, void *msg, int len)
 {
-   int err;
+   int err, id, msgid;
 
-   mtk_vcodec_debug(vpu, "id=%X", *(uint32_t *)msg);
+   msgid = *(uint32_t *)msg;
+   mtk_vcodec_debug(vpu, "id=%X", msgid);
 
vpu->failure = 0;
vpu->signaled = 0;
 
-   err = mtk_vcodec_fw_ipi_send(vpu->ctx->dev->fw_handler, vpu->id, msg,
+   if (vpu->ctx->dev->vdec_pdata->hw_arch == MTK_VDEC_LAT_SINGLE_CORE) {
+   if (msgid == AP_IPIMSG_DEC_CORE ||
+   msgid == AP_IPIMSG_DEC_CORE_END)
+   id = vpu->core_id;
+   else
+   id = vpu->id;
+   } else {
+   id = vpu->id;
+   }
+
+   err = mtk_vcodec_fw_ipi_send(vpu->ctx->dev->fw_handler, id, msg,
 len, 2000);
if (err) {
mtk_vcodec_err(vpu, "send fail vpu_id=%d msg_id=%X status=%d",
-  vpu->id, *(uint32_t *)msg, err);
+  id, msgid, err);
return err;
}
 
@@ -131,6 +142,7 @@ static int vcodec_send_ap_ipi(struct vdec_vpu_inst *vpu, 
unsigned int msg_id)
msg.vpu_inst_addr = vpu->inst_addr;
else
msg.inst_id = vpu->inst_id;
+   msg.codec_type = vpu->codec_type;
 
err = vcodec_vpu_send_msg(vpu, , sizeof(msg));
mtk_vcodec_debug(vpu, "- id=%X ret=%d", msg_id, err);
@@ -149,14 +161,25 @@ int vpu_dec_init(struct vdec_vpu_inst *vpu)
 
err = mtk_vcodec_fw_ipi_register(vpu->ctx->dev->fw_handler, vpu->id,
 vpu->handler, "vdec", NULL);
-   if (err != 0) {
+   if (err) {
mtk_vcodec_err(vpu, "vpu_ipi_register fail status=%d", err);
return err;
}
 
+   if (vpu->ctx->dev->vdec_pdata->hw_arch == MTK_VDEC_LAT_SINGLE_CORE) {
+   err = mtk_vcodec_fw_ipi_register(vpu->ctx->dev->fw_handler,
+vpu->core_id, vpu->handler,
+"vdec", NULL);
+   if (err) {
+   mtk_vcodec_err(vpu, "vpu_ipi_register core fail 
status=%d", err);
+   return err;
+   }
+   }
+
memset(, 0, sizeof(msg));
msg.msg_id = AP_IPIMSG_DEC_INIT;
msg.ap_inst_addr = (unsigned long)vpu;
+   msg.codec_type = vpu->codec_type;
 

[PATCH v14, 16/19] media: mtk-vcodec: Add core dec and dec end ipi msg

2021-12-14 Thread Yunfei Dong
Add core dec and dec end ipi msg: AP_IPIMSG_DEC_CORE/AP_IPIMSG_DEC_CORE_END.

Signed-off-by: Yunfei Dong 
Reviewed-by: AngeloGioacchino Del Regno 

---
 .../media/platform/mtk-vcodec/vdec_ipi_msg.h   |  4 
 .../media/platform/mtk-vcodec/vdec_vpu_if.c| 12 
 .../media/platform/mtk-vcodec/vdec_vpu_if.h| 18 ++
 3 files changed, 34 insertions(+)

diff --git a/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h 
b/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h
index 5f45a537beb4..9d8079c4f976 100644
--- a/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h
+++ b/drivers/media/platform/mtk-vcodec/vdec_ipi_msg.h
@@ -18,12 +18,16 @@ enum vdec_ipi_msgid {
AP_IPIMSG_DEC_END = 0xA002,
AP_IPIMSG_DEC_DEINIT = 0xA003,
AP_IPIMSG_DEC_RESET = 0xA004,
+   AP_IPIMSG_DEC_CORE = 0xA005,
+   AP_IPIMSG_DEC_CORE_END = 0xA006,
 
VPU_IPIMSG_DEC_INIT_ACK = 0xB000,
VPU_IPIMSG_DEC_START_ACK = 0xB001,
VPU_IPIMSG_DEC_END_ACK = 0xB002,
VPU_IPIMSG_DEC_DEINIT_ACK = 0xB003,
VPU_IPIMSG_DEC_RESET_ACK = 0xB004,
+   VPU_IPIMSG_DEC_CORE_ACK = 0xB005,
+   VPU_IPIMSG_DEC_CORE_END_ACK = 0xB006,
 };
 
 /**
diff --git a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c 
b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
index 5dffc459a33d..bfd8e87dceff 100644
--- a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
+++ b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.c
@@ -85,6 +85,8 @@ static void vpu_dec_ipi_handler(void *data, unsigned int len, 
void *priv)
case VPU_IPIMSG_DEC_END_ACK:
case VPU_IPIMSG_DEC_DEINIT_ACK:
case VPU_IPIMSG_DEC_RESET_ACK:
+   case VPU_IPIMSG_DEC_CORE_ACK:
+   case VPU_IPIMSG_DEC_CORE_END_ACK:
break;
 
default:
@@ -191,11 +193,21 @@ int vpu_dec_start(struct vdec_vpu_inst *vpu, uint32_t 
*data, unsigned int len)
return err;
 }
 
+int vpu_dec_core(struct vdec_vpu_inst *vpu)
+{
+   return vcodec_send_ap_ipi(vpu, AP_IPIMSG_DEC_CORE);
+}
+
 int vpu_dec_end(struct vdec_vpu_inst *vpu)
 {
return vcodec_send_ap_ipi(vpu, AP_IPIMSG_DEC_END);
 }
 
+int vpu_dec_core_end(struct vdec_vpu_inst *vpu)
+{
+   return vcodec_send_ap_ipi(vpu, AP_IPIMSG_DEC_CORE_END);
+}
+
 int vpu_dec_deinit(struct vdec_vpu_inst *vpu)
 {
return vcodec_send_ap_ipi(vpu, AP_IPIMSG_DEC_DEINIT);
diff --git a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.h 
b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.h
index c2ed5b6cab8b..ae24b75d1649 100644
--- a/drivers/media/platform/mtk-vcodec/vdec_vpu_if.h
+++ b/drivers/media/platform/mtk-vcodec/vdec_vpu_if.h
@@ -82,4 +82,22 @@ int vpu_dec_deinit(struct vdec_vpu_inst *vpu);
  */
 int vpu_dec_reset(struct vdec_vpu_inst *vpu);
 
+/**
+ * vpu_dec_core - core start decoding, basically the function will be invoked 
once
+ * every frame.
+ *
+ * @vpu : instance for vdec_vpu_inst
+ */
+int vpu_dec_core(struct vdec_vpu_inst *vpu);
+
+/**
+ * vpu_dec_core_end - core end decoding, basically the function will be 
invoked once
+ *   when core HW decoding done and receive interrupt 
successfully. The
+ *   decoder in VPU will updata hardware information and deinit 
hardware
+ *   and check if there is a new decoded frame available to 
display.
+ *
+ * @vpu : instance for vdec_vpu_inst
+ */
+int vpu_dec_core_end(struct vdec_vpu_inst *vpu);
+
 #endif
-- 
2.25.1



[PATCH v14, 11/19] media: mtk-vcodec: Generalize power and clock on/off interfaces

2021-12-14 Thread Yunfei Dong
Generalizes power and clock on/off interfaces to support different hardware.

Reviewed-by: AngeloGioacchino Del Regno 

Signed-off-by: Yunfei Dong 
---
 .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c  |  6 +-
 .../platform/mtk-vcodec/mtk_vcodec_dec_hw.c   |  2 +-
 .../platform/mtk-vcodec/mtk_vcodec_dec_hw.h   |  4 +
 .../platform/mtk-vcodec/mtk_vcodec_dec_pm.c   | 76 +--
 .../platform/mtk-vcodec/mtk_vcodec_dec_pm.h   |  8 +-
 .../platform/mtk-vcodec/mtk_vcodec_drv.h  |  2 +
 .../platform/mtk-vcodec/mtk_vcodec_util.c | 59 +++---
 .../platform/mtk-vcodec/mtk_vcodec_util.h |  8 +-
 .../media/platform/mtk-vcodec/vdec_drv_if.c   | 21 ++---
 9 files changed, 146 insertions(+), 40 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
index 5ec7f5a2e2cf..7af49d0be737 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
@@ -49,7 +49,7 @@ static irqreturn_t mtk_vcodec_dec_irq_handler(int irq, void 
*priv)
void __iomem *vdec_misc_addr = dev->reg_base[VDEC_MISC] +
VDEC_IRQ_CFG_REG;
 
-   ctx = mtk_vcodec_get_curr_ctx(dev);
+   ctx = mtk_vcodec_get_curr_ctx(dev, MTK_VDEC_CORE);
 
/* check if HW active or not */
cg_status = readl(dev->reg_base[0]);
@@ -196,7 +196,7 @@ static int fops_vcodec_open(struct file *file)
mtk_vcodec_dec_set_default_params(ctx);
 
if (v4l2_fh_is_singular(>fh)) {
-   ret = mtk_vcodec_dec_pw_on(>pm);
+   ret = mtk_vcodec_dec_pw_on(dev, MTK_VDEC_LAT0);
if (ret < 0)
goto err_load_fw;
/*
@@ -256,7 +256,7 @@ static int fops_vcodec_release(struct file *file)
mtk_vcodec_dec_release(ctx);
 
if (v4l2_fh_is_singular(>fh))
-   mtk_vcodec_dec_pw_off(>pm);
+   mtk_vcodec_dec_pw_off(dev, MTK_VDEC_LAT0);
v4l2_fh_del(>fh);
v4l2_fh_exit(>fh);
v4l2_ctrl_handler_free(>ctrl_hdl);
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.c
index b149c3058995..643cee119b60 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.c
@@ -65,7 +65,7 @@ static irqreturn_t mtk_vdec_hw_irq_handler(int irq, void 
*priv)
void __iomem *vdec_misc_addr = dev->reg_base[VDEC_HW_MISC] +
VDEC_IRQ_CFG_REG;
 
-   ctx = mtk_vcodec_get_curr_ctx(dev->main_dev);
+   ctx = mtk_vcodec_get_curr_ctx(dev->main_dev, dev->hw_idx);
 
/* check if HW active or not */
cg_status = readl(dev->reg_base[VDEC_HW_SYS]);
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.h
index 0db0c8c310da..c0cd0cdab9ee 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.h
@@ -32,6 +32,8 @@ enum mtk_vdec_hw_reg_idx {
  * @main_dev: main device
  * @reg_base: Mapped address of MTK Vcodec registers.
  *
+ * @curr_ctx: the context that is waiting for codec hardware
+ *
  * @dec_irq: decoder irq resource
  * @pm: power management control
  * @hw_idx: each hardware index
@@ -41,6 +43,8 @@ struct mtk_vdec_hw_dev {
struct mtk_vcodec_dev *main_dev;
void __iomem *reg_base[VDEC_HW_MAX];
 
+   struct mtk_vcodec_ctx *curr_ctx;
+
int dec_irq;
struct mtk_vcodec_pm pm;
int hw_idx;
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
index 221cf60e9fbf..4cf03d38d141 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
@@ -5,11 +5,13 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 
+#include "mtk_vcodec_dec_hw.h"
 #include "mtk_vcodec_dec_pm.h"
 #include "mtk_vcodec_util.h"
 
@@ -86,10 +88,23 @@ void mtk_vcodec_release_dec_pm(struct mtk_vcodec_pm *pm)
 }
 EXPORT_SYMBOL_GPL(mtk_vcodec_release_dec_pm);
 
-int mtk_vcodec_dec_pw_on(struct mtk_vcodec_pm *pm)
+int mtk_vcodec_dec_pw_on(struct mtk_vcodec_dev *vdec_dev, int hw_idx)
 {
+   struct mtk_vdec_hw_dev *subdev_dev;
+   struct mtk_vcodec_pm *pm;
int ret;
 
+   if (vdec_dev->vdec_pdata->is_subdev_supported) {
+   subdev_dev = mtk_vcodec_get_hw_dev(vdec_dev, hw_idx);
+   if (!subdev_dev) {
+   mtk_v4l2_err("Failed to get hw dev\n");
+   return -EINVAL;
+   }
+   pm = _dev->pm;
+   } else {
+   pm = _dev->pm;
+   }
+
ret = pm_runtime_resume_and_get(pm->dev);
if (ret)
mtk_v4l2_err("pm_runtime_resume_and_get 

[PATCH v14, 12/19] media: mtk-vcodec: Add new interface to lock different hardware

2021-12-14 Thread Yunfei Dong
For add new hardware, not only need to lock lat hardware, also
need to lock core hardware in case of different instance start
to decoder at the same time.

Signed-off-by: Yunfei Dong 
Reviewed-by: AngeloGioacchino Del Regno 

---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 4 ++--
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 6 +++---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
index 2b334a8a81c6..130ecef2e766 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c
@@ -105,12 +105,12 @@ static int vidioc_decoder_cmd(struct file *file, void 
*priv,
 
 void mtk_vdec_unlock(struct mtk_vcodec_ctx *ctx)
 {
-   mutex_unlock(>dev->dec_mutex);
+   mutex_unlock(>dev->dec_mutex[ctx->hw_id]);
 }
 
 void mtk_vdec_lock(struct mtk_vcodec_ctx *ctx)
 {
-   mutex_lock(>dev->dec_mutex);
+   mutex_lock(>dev->dec_mutex[ctx->hw_id]);
 }
 
 void mtk_vcodec_dec_release(struct mtk_vcodec_ctx *ctx)
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
index 7af49d0be737..63b8a2341835 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
@@ -282,7 +282,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
struct video_device *vfd_dec;
phandle rproc_phandle;
enum mtk_vcodec_fw_type fw_type;
-   int ret;
+   int i, ret;
 
dev = devm_kzalloc(>dev, sizeof(*dev), GFP_KERNEL);
if (!dev)
@@ -314,8 +314,8 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
goto err_dec_pm;
}
 
-   mutex_init(>dec_mutex);
-   mutex_init(>dev_mutex);
+   for (i = 0; i < MTK_VDEC_HW_MAX; i++)
+   mutex_init(>dec_mutex[i]);
spin_lock_init(>irqlock);
 
snprintf(dev->v4l2_dev.name, sizeof(dev->v4l2_dev.name), "%s",
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
index adc5998ed424..517515ee9ac4 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
@@ -500,7 +500,7 @@ struct mtk_vcodec_dev {
int dec_irq;
int enc_irq;
 
-   struct mutex dec_mutex;
+   struct mutex dec_mutex[MTK_VDEC_HW_MAX];
struct mutex enc_mutex;
 
struct mtk_vcodec_pm pm;
-- 
2.25.1



[PATCH v14, 10/19] media: mtk-vcodec: Add msg queue feature for lat and core architecture

2021-12-14 Thread Yunfei Dong
For lat and core architecture, lat thread will send message to core
thread when lat decode done. Core hardware will use the message
from lat to decode, then free message to lat thread when decode done.

Signed-off-by: Yunfei Dong 
---
 drivers/media/platform/mtk-vcodec/Makefile|   1 +
 .../platform/mtk-vcodec/mtk_vcodec_drv.h  |   9 +
 .../platform/mtk-vcodec/vdec_msg_queue.c  | 260 ++
 .../platform/mtk-vcodec/vdec_msg_queue.h  | 143 ++
 4 files changed, 413 insertions(+)
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_msg_queue.c
 create mode 100644 drivers/media/platform/mtk-vcodec/vdec_msg_queue.h

diff --git a/drivers/media/platform/mtk-vcodec/Makefile 
b/drivers/media/platform/mtk-vcodec/Makefile
index c61bfb179bcc..359619653a0e 100644
--- a/drivers/media/platform/mtk-vcodec/Makefile
+++ b/drivers/media/platform/mtk-vcodec/Makefile
@@ -12,6 +12,7 @@ mtk-vcodec-dec-y := vdec/vdec_h264_if.o \
mtk_vcodec_dec_drv.o \
vdec_drv_if.o \
vdec_vpu_if.o \
+   vdec_msg_queue.o \
mtk_vcodec_dec.o \
mtk_vcodec_dec_stateful.o \
mtk_vcodec_dec_stateless.o \
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
index f62752fbab8c..cbd602b7ecbb 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
@@ -15,7 +15,9 @@
 #include 
 #include 
 #include 
+
 #include "mtk_vcodec_util.h"
+#include "vdec_msg_queue.h"
 
 #define MTK_VCODEC_DRV_NAME"mtk_vcodec_drv"
 #define MTK_VCODEC_DEC_NAME"mtk-vcodec-dec"
@@ -282,6 +284,8 @@ struct vdec_pic_info {
  * @decoded_frame_cnt: number of decoded frames
  * @lock: protect variables accessed by V4L2 threads and worker thread such as
  *   mtk_video_dec_buf.
+ *
+ * @msg_queue: msg queue used to store lat buffer information.
  */
 struct mtk_vcodec_ctx {
enum mtk_instance_type type;
@@ -325,6 +329,7 @@ struct mtk_vcodec_ctx {
int decoded_frame_cnt;
struct mutex lock;
 
+   struct vdec_msg_queue msg_queue;
 };
 
 enum mtk_chip {
@@ -457,6 +462,8 @@ struct mtk_vcodec_enc_pdata {
  * @dec_capability: used to identify decode capability, ex: 4k
  * @enc_capability: used to identify encode capability
  *
+ * @msg_queue_core_ctx: msg queue context used for core workqueue
+ *
  * @subdev_dev: subdev hardware device
  * @subdev_prob_done: check whether all used hw device is prob done
  * @subdev_bitmap: used to record hardware is ready or not
@@ -498,6 +505,8 @@ struct mtk_vcodec_dev {
unsigned int dec_capability;
unsigned int enc_capability;
 
+   struct vdec_msg_queue_ctx msg_queue_core_ctx;
+
void *subdev_dev[MTK_VDEC_HW_MAX];
int (*subdev_prob_done)(struct mtk_vcodec_dev *vdec_dev);
DECLARE_BITMAP(subdev_bitmap, MTK_VDEC_HW_MAX);
diff --git a/drivers/media/platform/mtk-vcodec/vdec_msg_queue.c 
b/drivers/media/platform/mtk-vcodec/vdec_msg_queue.c
new file mode 100644
index ..913aefa67618
--- /dev/null
+++ b/drivers/media/platform/mtk-vcodec/vdec_msg_queue.c
@@ -0,0 +1,260 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2021 MediaTek Inc.
+ * Author: Yunfei Dong 
+ */
+
+#include 
+#include 
+#include 
+
+#include "mtk_vcodec_dec_pm.h"
+#include "mtk_vcodec_drv.h"
+#include "vdec_msg_queue.h"
+
+#define VDEC_MSG_QUEUE_TIMEOUT_MS 1500
+
+/* the size used to store lat slice header information */
+#define VDEC_LAT_SLICE_HEADER_SZ(640 * SZ_1K)
+
+/* the size used to store avc error information */
+#define VDEC_ERR_MAP_SZ_AVC (17 * SZ_1K)
+
+/* core will read the trans buffer which decoded by lat to decode again.
+ * The trans buffer size of FHD and 4K bitstreams are different.
+ */
+static int vde_msg_queue_get_trans_size(int width, int height)
+{
+   if (width > 1920 || height > 1088)
+   return 30 * SZ_1M;
+   else
+   return 6 * SZ_1M;
+}
+
+void vdec_msg_queue_init_ctx(struct vdec_msg_queue_ctx *ctx, int 
hardware_index)
+{
+   init_waitqueue_head(>ready_to_use);
+   INIT_LIST_HEAD(>ready_queue);
+   spin_lock_init(>ready_lock);
+   ctx->ready_num = 0;
+   ctx->hardware_index = hardware_index;
+}
+
+static struct list_head *vdec_get_buf_list(int hardware_index, struct 
vdec_lat_buf *buf)
+{
+   switch (hardware_index) {
+   case MTK_VDEC_CORE:
+   return >core_list;
+   case MTK_VDEC_LAT0:
+   return >lat_list;
+   default:
+   return NULL;
+   }
+}
+
+int vdec_msg_queue_qbuf(struct vdec_msg_queue_ctx *msg_ctx, struct 
vdec_lat_buf *buf)
+{
+   struct list_head *head;
+
+   head = vdec_get_buf_list(msg_ctx->hardware_index, buf);
+   if (!head) {
+   mtk_v4l2_err("fail to qbuf: %d",msg_ctx->hardware_index);
+   return -EINVAL;
+   }
+
+   

[PATCH v14, 14/19] media: mtk-vcodec: Support 34bits dma address for vdec

2021-12-14 Thread Yunfei Dong
Use the dma_set_mask_and_coherent helper to set vdec
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 VDEC actually locate, it
depends on the dma-ranges property of vdec dtsi node.

Reviewed-by: AngeloGioacchino Del Regno 

Signed-off-by: Yunfei Dong 
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
index a019f3fed0ff..41ae38c56871 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
@@ -325,6 +325,14 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
}
}
 
+   if (of_get_property(pdev->dev.of_node, "dma-ranges", NULL)) {
+   ret = dma_set_mask_and_coherent(>dev, DMA_BIT_MASK(34));
+   if (ret) {
+   mtk_v4l2_err("Failed to set mask");
+   goto err_core_workq;
+   }
+   }
+
for (i = 0; i < MTK_VDEC_HW_MAX; i++)
mutex_init(>dec_mutex[i]);
spin_lock_init(>irqlock);
-- 
2.25.1



[PATCH v14, 15/19] dt-bindings: media: mtk-vcodec: Adds decoder dt-bindings for mt8192

2021-12-14 Thread Yunfei Dong
Adds decoder dt-bindings for mt8192.

Reviewed-by: Rob Herring 
Signed-off-by: Yunfei Dong 
---
 .../media/mediatek,vcodec-subdev-decoder.yaml | 265 ++
 1 file changed, 265 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml

diff --git 
a/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml 
b/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml
new file mode 100644
index ..d587fc3e39fb
--- /dev/null
+++ 
b/Documentation/devicetree/bindings/media/mediatek,vcodec-subdev-decoder.yaml
@@ -0,0 +1,265 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/media/mediatek,vcodec-subdev-decoder.yaml#;
+$schema: "http://devicetree.org/meta-schemas/core.yaml#;
+
+title: Mediatek Video Decode Accelerator With Multi Hardware
+
+maintainers:
+  - Yunfei Dong 
+
+description: |
+  Mediatek Video Decode is the video decode hardware present in Mediatek
+  SoCs which supports high resolution decoding functionalities. Required
+  parent and child device node.
+
+  About the Decoder Hardware Block Diagram, please check below:
+
++-++
+| ||
+| input -> lat HW -> lat buffer --|--> lat buffer -> core HW -> output |
+|||   | || |
++||---+-||-+
+  lat workqueue   |  core workqueue 

+
-||-||--
+ || ||  
+ \/ \/
+   +--+
+   |enable/disable|
+   |   clk powerirqiommu  |
+   | (lat/lat soc/core0/core1)|
+   +--+
+
+  As above, there are parent and child devices, child mean each hardware. The 
child device
+  controls the information of each hardware independent which include 
clk/power/irq.
+
+  There are two workqueues in parent device: lat workqueue and core workqueue. 
They are used
+  to lat and core hardware deocder. Lat workqueue need to get input bitstream 
and lat buffer,
+  then enable lat to decode, writing the result to lat buffer, dislabe 
hardware when lat decode
+  done. Core workqueue need to get lat buffer and output buffer, then enable 
core to decode,
+  writing the result to output buffer, disable hardware when core decode done. 
These two
+  hardwares will decode each frame cyclically.
+
+  For the smi common may not the same for each hardware, can't combine all 
hardware in one node,
+  or leading to iommu fault when access dram data.
+
+properties:
+  compatible:
+const: mediatek,mt8192-vcodec-dec
+
+  reg:
+maxItems: 1
+
+  iommus:
+minItems: 1
+maxItems: 32
+description: |
+  List of the hardware port in respective IOMMU block for current Socs.
+  Refer to bindings/iommu/mediatek,iommu.yaml.
+
+  mediatek,scp:
+$ref: /schemas/types.yaml#/definitions/phandle
+maxItems: 1
+description: |
+  The node of system control processor (SCP), using
+  the remoteproc & rpmsg framework.
+
+  dma-ranges:
+maxItems: 1
+description: |
+  Describes the physical address space of IOMMU maps to memory.
+
+  "#address-cells":
+const: 1
+
+  "#size-cells":
+const: 1
+
+  ranges: true
+
+# Required child node:
+patternProperties:
+  '^vcodec-lat@[0-9a-f]+$':
+type: object
+
+properties:
+  compatible:
+const: mediatek,mtk-vcodec-lat
+
+  reg:
+maxItems: 1
+
+  interrupts:
+maxItems: 1
+
+  iommus:
+minItems: 1
+maxItems: 32
+description: |
+  List of the hardware port in respective IOMMU block for current Socs.
+  Refer to bindings/iommu/mediatek,iommu.yaml.
+
+  clocks:
+maxItems: 5
+
+  clock-names:
+items:
+  - const: sel
+  - const: soc-vdec
+  - const: soc-lat
+  - const: vdec
+  - const: top
+
+  assigned-clocks:
+maxItems: 1
+
+  assigned-clock-parents:
+maxItems: 1
+
+  power-domains:
+maxItems: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - iommus
+  - clocks
+  - clock-names
+  - assigned-clocks
+  - assigned-clock-parents
+  - power-domains
+
+additionalProperties: false
+
+  '^vcodec-core@[0-9a-f]+$':
+type: object
+
+properties:
+  compatible:
+const: 

[PATCH v14, 06/19] media: mtk-vcodec: Add to support multi hardware decode

2021-12-14 Thread Yunfei Dong
There are more than two hardwares for decoder: LAT0, LAT1 and CORE. In order to
manage these hardwares, register each hardware as independent platform device
for the larbs are different.

Each hardware module controls its own information which includes 
interrupt/power/
clocks/registers.

Calling of_platform_populate in parent device, and use subdev_bitmap to record
whether the hardwares are registered.

Reviewed-by: Steve Cho 
Signed-off-by: Yunfei Dong 
---
Just change some function position in case of ko dependency.
---
 drivers/media/platform/mtk-vcodec/Makefile|   5 +-
 .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c  |  85 +---
 .../platform/mtk-vcodec/mtk_vcodec_dec_hw.c   | 198 ++
 .../platform/mtk-vcodec/mtk_vcodec_dec_hw.h   |  49 +
 .../mtk-vcodec/mtk_vcodec_dec_stateful.c  |   1 +
 .../mtk-vcodec/mtk_vcodec_dec_stateless.c |   3 +
 .../platform/mtk-vcodec/mtk_vcodec_drv.h  |  21 ++
 7 files changed, 330 insertions(+), 32 deletions(-)
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.c
 create mode 100644 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.h

diff --git a/drivers/media/platform/mtk-vcodec/Makefile 
b/drivers/media/platform/mtk-vcodec/Makefile
index ca8e9e7a9c4e..c61bfb179bcc 100644
--- a/drivers/media/platform/mtk-vcodec/Makefile
+++ b/drivers/media/platform/mtk-vcodec/Makefile
@@ -2,7 +2,8 @@
 
 obj-$(CONFIG_VIDEO_MEDIATEK_VCODEC) += mtk-vcodec-dec.o \
   mtk-vcodec-enc.o \
-  mtk-vcodec-common.o
+  mtk-vcodec-common.o \
+  mtk-vcodec-dec-hw.o
 
 mtk-vcodec-dec-y := vdec/vdec_h264_if.o \
vdec/vdec_vp8_if.o \
@@ -16,6 +17,8 @@ mtk-vcodec-dec-y := vdec/vdec_h264_if.o \
mtk_vcodec_dec_stateless.o \
mtk_vcodec_dec_pm.o \
 
+mtk-vcodec-dec-hw-y := mtk_vcodec_dec_hw.o
+
 mtk-vcodec-enc-y := venc/venc_vp8_if.o \
venc/venc_h264_if.o \
mtk_vcodec_enc.o \
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
index b7a51e96d4ba..2b4b81543a27 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
@@ -18,16 +18,12 @@
 
 #include "mtk_vcodec_drv.h"
 #include "mtk_vcodec_dec.h"
+#include "mtk_vcodec_dec_hw.h"
 #include "mtk_vcodec_dec_pm.h"
 #include "mtk_vcodec_intr.h"
 #include "mtk_vcodec_util.h"
 #include "mtk_vcodec_fw.h"
 
-#define VDEC_HW_ACTIVE 0x10
-#define VDEC_IRQ_CFG   0x11
-#define VDEC_IRQ_CLR   0x10
-#define VDEC_IRQ_CFG_REG   0xa4
-
 module_param(mtk_v4l2_dbg_level, int, 0644);
 module_param(mtk_vcodec_dbg, bool, 0644);
 
@@ -95,6 +91,42 @@ static int mtk_vcodec_get_reg_bases(struct mtk_vcodec_dev 
*dev)
return 0;
 }
 
+static int mtk_vcodec_init_dec_resources(struct mtk_vcodec_dev *dev)
+{
+   struct platform_device *pdev = dev->plat_dev;
+   int ret;
+
+   ret = mtk_vcodec_get_reg_bases(dev);
+   if (ret)
+   return ret;
+
+   if (dev->vdec_pdata->is_subdev_supported)
+   return 0;
+
+   dev->dec_irq = platform_get_irq(pdev, 0);
+   if (dev->dec_irq < 0) {
+   dev_err(>dev, "failed to get irq number");
+   return dev->dec_irq;
+   }
+
+   irq_set_status_flags(dev->dec_irq, IRQ_NOAUTOEN);
+   ret = devm_request_irq(>dev, dev->dec_irq,
+   mtk_vcodec_dec_irq_handler, 0, pdev->name, dev);
+   if (ret) {
+   dev_err(>dev, "failed to install dev->dec_irq %d (%d)",
+   dev->dec_irq, ret);
+   return ret;
+   }
+
+   ret = mtk_vcodec_init_dec_pm(pdev, >pm);
+   if (ret < 0) {
+   dev_err(>dev, "failed to get mt vcodec clock source");
+   return ret;
+   }
+
+   return 0;
+}
+
 static int fops_vcodec_open(struct file *file)
 {
struct mtk_vcodec_dev *dev = video_drvdata(file);
@@ -116,6 +148,11 @@ static int fops_vcodec_open(struct file *file)
init_waitqueue_head(>queue);
mutex_init(>lock);
 
+   if (dev->vdec_pdata->is_subdev_supported && dev->subdev_prob_done) {
+   ret = dev->subdev_prob_done(dev);
+   if (ret)
+   goto err_ctrls_setup;
+   }
ctx->type = MTK_INST_DECODER;
ret = dev->vdec_pdata->ctrls_setup(ctx);
if (ret) {
@@ -220,7 +257,6 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
 {
struct mtk_vcodec_dev *dev;
struct video_device *vfd_dec;
-   struct resource *res;
phandle rproc_phandle;
enum mtk_vcodec_fw_type fw_type;
int ret;
@@ -249,32 +285,10 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
if (IS_ERR(dev->fw_handler))
return PTR_ERR(dev->fw_handler);
 
-

[PATCH v14, 08/19] media: mtk-vcodec: Use pure single core for MT8183

2021-12-14 Thread Yunfei Dong
Separates different architecture for hardware: pure_sin_core
and lat_sin_core. MT8183 is pure single core. Uses .hw_arch to
distinguish.

Reviewed-by: AngeloGioacchino Del Regno 

Signed-off-by: Yunfei Dong 
---
 .../platform/mtk-vcodec/mtk_vcodec_dec_stateful.c  |  1 +
 .../platform/mtk-vcodec/mtk_vcodec_dec_stateless.c |  2 ++
 drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h | 10 ++
 3 files changed, 13 insertions(+)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateful.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateful.c
index c7f9259ad094..04ca43c77e5f 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateful.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateful.c
@@ -626,4 +626,5 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8173_pdata = {
.worker = mtk_vdec_worker,
.flush_decoder = mtk_vdec_flush_decoder,
.is_subdev_supported = false,
+   .hw_arch = MTK_VDEC_PURE_SINGLE_CORE,
 };
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c
index f76cfd07c78d..6c67b7f65f9c 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c
@@ -358,6 +358,7 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8183_pdata = {
.worker = mtk_vdec_worker,
.flush_decoder = mtk_vdec_flush_decoder,
.is_subdev_supported = false,
+   .hw_arch = MTK_VDEC_PURE_SINGLE_CORE,
 };
 
 /* This platform data is used for one lat and one core architecture. */
@@ -376,4 +377,5 @@ const struct mtk_vcodec_dec_pdata mtk_lat_sig_core_pdata = {
.worker = mtk_vdec_worker,
.flush_decoder = mtk_vdec_flush_decoder,
.is_subdev_supported = true,
+   .hw_arch = MTK_VDEC_LAT_SINGLE_CORE,
 };
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
index 7f97fbf0f073..6d07bf997cc1 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
@@ -324,6 +324,14 @@ enum mtk_chip {
MTK_MT8195,
 };
 
+/**
+ * struct mtk_vdec_hw_arch - Used to separate different hardware architecture
+ */
+enum mtk_vdec_hw_arch {
+   MTK_VDEC_PURE_SINGLE_CORE,
+   MTK_VDEC_LAT_SINGLE_CORE,
+};
+
 /**
  * struct mtk_vcodec_dec_pdata - compatible data for each IC
  * @init_vdec_params: init vdec params
@@ -342,6 +350,7 @@ enum mtk_chip {
  * @num_framesizes: count of video decoder frame sizes
  *
  * @chip: chip this decoder is compatible with
+ * @hw_arch: hardware arch is used to separate pure_sin_core and lat_sin_core
  *
  * @is_subdev_supported: whether support parent-node architecture(subdev)
  * @uses_stateless_api: whether the decoder uses the stateless API with 
requests
@@ -364,6 +373,7 @@ struct mtk_vcodec_dec_pdata {
const int num_framesizes;
 
enum mtk_chip chip;
+   enum mtk_vdec_hw_arch hw_arch;
 
bool is_subdev_supported;
bool uses_stateless_api;
-- 
2.25.1



[PATCH v14, 09/19] media: mtk-vcodec: Add irq interface for multi hardware

2021-12-14 Thread Yunfei Dong
Adds irq interface for multi hardware.

Reviewed-by: AngeloGioacchino Del Regno 

Signed-off-by: Yunfei Dong 
---
 .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c  | 33 ---
 .../platform/mtk-vcodec/mtk_vcodec_dec_hw.c   |  2 +-
 .../platform/mtk-vcodec/mtk_vcodec_drv.h  | 25 ++
 .../platform/mtk-vcodec/mtk_vcodec_enc_drv.c  |  4 +--
 .../platform/mtk-vcodec/mtk_vcodec_intr.c | 27 +++
 .../platform/mtk-vcodec/mtk_vcodec_intr.h |  4 +--
 .../platform/mtk-vcodec/vdec/vdec_h264_if.c   |  2 +-
 .../mtk-vcodec/vdec/vdec_h264_req_if.c|  2 +-
 .../platform/mtk-vcodec/vdec/vdec_vp8_if.c|  2 +-
 .../platform/mtk-vcodec/vdec/vdec_vp9_if.c|  2 +-
 .../platform/mtk-vcodec/venc/venc_h264_if.c   |  2 +-
 .../platform/mtk-vcodec/venc/venc_vp8_if.c|  2 +-
 12 files changed, 69 insertions(+), 38 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
index 2b4b81543a27..5ec7f5a2e2cf 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
@@ -27,6 +27,19 @@
 module_param(mtk_v4l2_dbg_level, int, 0644);
 module_param(mtk_vcodec_dbg, bool, 0644);
 
+static int mtk_vcodec_get_hw_count(struct mtk_vcodec_dev *dev)
+{
+   switch (dev->vdec_pdata->hw_arch) {
+   case MTK_VDEC_PURE_SINGLE_CORE:
+   return MTK_VDEC_ONE_CORE;
+   case MTK_VDEC_LAT_SINGLE_CORE:
+   return MTK_VDEC_ONE_LAT_ONE_CORE;
+   default:
+   mtk_v4l2_err("hw arch %d not supported", 
dev->vdec_pdata->hw_arch);
+   return MTK_VDEC_NO_HW;
+   }
+}
+
 static irqreturn_t mtk_vcodec_dec_irq_handler(int irq, void *priv)
 {
struct mtk_vcodec_dev *dev = priv;
@@ -58,7 +71,7 @@ static irqreturn_t mtk_vcodec_dec_irq_handler(int irq, void 
*priv)
writel((readl(vdec_misc_addr) & ~VDEC_IRQ_CLR),
dev->reg_base[VDEC_MISC] + VDEC_IRQ_CFG_REG);
 
-   wake_up_ctx(ctx, MTK_INST_IRQ_RECEIVED);
+   wake_up_ctx(ctx, MTK_INST_IRQ_RECEIVED, 0);
 
mtk_v4l2_debug(3,
"mtk_vcodec_dec_irq_handler :wake up ctx %d, 
dec_done_status=%x",
@@ -131,7 +144,7 @@ static int fops_vcodec_open(struct file *file)
 {
struct mtk_vcodec_dev *dev = video_drvdata(file);
struct mtk_vcodec_ctx *ctx = NULL;
-   int ret = 0;
+   int ret = 0, i, hw_count;
struct vb2_queue *src_vq;
 
ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
@@ -145,14 +158,24 @@ static int fops_vcodec_open(struct file *file)
v4l2_fh_add(>fh);
INIT_LIST_HEAD(>list);
ctx->dev = dev;
-   init_waitqueue_head(>queue);
-   mutex_init(>lock);
+   if (ctx->dev->vdec_pdata->is_subdev_supported) {
+   hw_count = mtk_vcodec_get_hw_count(dev);
+   if (!hw_count || !dev->subdev_prob_done) {
+   ret = -EINVAL;
+   goto err_ctrls_setup;
+   }
 
-   if (dev->vdec_pdata->is_subdev_supported && dev->subdev_prob_done) {
ret = dev->subdev_prob_done(dev);
if (ret)
goto err_ctrls_setup;
+
+   for (i = 0; i < hw_count; i++)
+   init_waitqueue_head(>queue[i]);
+   } else {
+   init_waitqueue_head(>queue[0]);
}
+   mutex_init(>lock);
+
ctx->type = MTK_INST_DECODER;
ret = dev->vdec_pdata->ctrls_setup(ctx);
if (ret) {
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.c
index b6703b444827..b149c3058995 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_hw.c
@@ -84,7 +84,7 @@ static irqreturn_t mtk_vdec_hw_irq_handler(int irq, void 
*priv)
writel(dec_done_status | VDEC_IRQ_CFG, vdec_misc_addr);
writel(dec_done_status & ~VDEC_IRQ_CLR, vdec_misc_addr);
 
-   wake_up_ctx(ctx, MTK_INST_IRQ_RECEIVED);
+   wake_up_ctx(ctx, MTK_INST_IRQ_RECEIVED, dev->hw_idx);
 
mtk_v4l2_debug(3, "wake up ctx %d, dec_done_status=%x",
ctx->id, dec_done_status);
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
index 6d07bf997cc1..f62752fbab8c 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
@@ -104,6 +104,16 @@ enum mtk_vdec_hw_id {
MTK_VDEC_HW_MAX,
 };
 
+/**
+ * struct mtk_vdec_hw_count - Supported hardware count
+ */
+enum mtk_vdec_hw_count {
+   MTK_VDEC_NO_HW = 0,
+   MTK_VDEC_ONE_CORE,
+   MTK_VDEC_ONE_LAT_ONE_CORE,
+   MTK_VDEC_MAX_HW_COUNT,
+};
+
 /*
  * struct mtk_video_fmt - Structure used to store information about 
pixelformats
  */
@@ -293,9 +303,9 @@ struct mtk_vcodec_ctx {
struct 

[PATCH v14, 07/19] dt-bindings: media: mtk-vcodec: Separate video encoder and decoder dt-bindings

2021-12-14 Thread Yunfei Dong
Separate decoder and encoder document for the dts are big difference.

Reviewed-by: Rob Herring
Signed-off-by: Yunfei Dong 
---
 .../media/mediatek,vcodec-decoder.yaml| 176 +
 .../media/mediatek,vcodec-encoder.yaml| 187 ++
 .../bindings/media/mediatek-vcodec.txt| 131 
 3 files changed, 363 insertions(+), 131 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/media/mediatek,vcodec-decoder.yaml
 create mode 100644 
Documentation/devicetree/bindings/media/mediatek,vcodec-encoder.yaml
 delete mode 100644 Documentation/devicetree/bindings/media/mediatek-vcodec.txt

diff --git 
a/Documentation/devicetree/bindings/media/mediatek,vcodec-decoder.yaml 
b/Documentation/devicetree/bindings/media/mediatek,vcodec-decoder.yaml
new file mode 100644
index ..df1d677098fd
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/mediatek,vcodec-decoder.yaml
@@ -0,0 +1,176 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/media/mediatek,vcodec-decoder.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Mediatek Video Decode Accelerator
+
+maintainers:
+  - Yunfei Dong 
+
+description: |+
+  Mediatek Video Decode is the video decode hardware present in Mediatek
+  SoCs which supports high resolution decoding functionalities.
+
+properties:
+  compatible:
+enum:
+  - mediatek,mt8173-vcodec-dec
+  - mediatek,mt8183-vcodec-dec
+
+  reg:
+maxItems: 12
+
+  interrupts:
+maxItems: 1
+
+  clocks:
+maxItems: 8
+
+  clock-names:
+items:
+  - const: vcodecpll
+  - const: univpll_d2
+  - const: clk_cci400_sel
+  - const: vdec_sel
+  - const: vdecpll
+  - const: vencpll
+  - const: venc_lt_sel
+  - const: vdec_bus_clk_src
+
+  assigned-clocks: true
+
+  assigned-clock-parents: true
+
+  assigned-clock-rates: true
+
+  power-domains:
+maxItems: 1
+
+  iommus:
+minItems: 1
+maxItems: 32
+description: |
+  List of the hardware port in respective IOMMU block for current Socs.
+  Refer to bindings/iommu/mediatek,iommu.yaml.
+
+  dma-ranges:
+maxItems: 1
+description: |
+  Describes the physical address space of IOMMU maps to memory.
+
+  mediatek,larb:
+$ref: /schemas/types.yaml#/definitions/phandle
+maxItems: 1
+description: |
+  Must contain the local arbiters in the current Socs.
+
+  mediatek,vpu:
+$ref: /schemas/types.yaml#/definitions/phandle
+maxItems: 1
+description:
+  Describes point to vpu.
+
+  mediatek,scp:
+$ref: /schemas/types.yaml#/definitions/phandle
+maxItems: 1
+description:
+  Describes point to scp.
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+  - iommus
+  - assigned-clocks
+  - assigned-clock-parents
+
+allOf:
+  - if:
+  properties:
+compatible:
+  contains:
+enum:
+  - mediatek,mt8183-vcodec-dec
+
+then:
+  required:
+- mediatek,scp
+
+  - if:
+  properties:
+compatible:
+  contains:
+enum:
+  - mediatek,mt8173-vcodec-dec
+
+then:
+  required:
+- mediatek,vpu
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+#include 
+#include 
+#include 
+#include 
+
+vcodec_dec: vcodec@1600 {
+  compatible = "mediatek,mt8173-vcodec-dec";
+  reg = <0x1600 0x100>,   /*VDEC_SYS*/
+  <0x1602 0x1000>,  /*VDEC_MISC*/
+  <0x16021000 0x800>,   /*VDEC_LD*/
+  <0x16021800 0x800>,   /*VDEC_TOP*/
+  <0x16022000 0x1000>,  /*VDEC_CM*/
+  <0x16023000 0x1000>,  /*VDEC_AD*/
+  <0x16024000 0x1000>,  /*VDEC_AV*/
+  <0x16025000 0x1000>,  /*VDEC_PP*/
+  <0x16026800 0x800>,   /*VP8_VD*/
+  <0x16027000 0x800>,   /*VP6_VD*/
+  <0x16027800 0x800>,   /*VP8_VL*/
+  <0x16028400 0x400>;   /*VP9_VD*/
+  interrupts = ;
+  mediatek,larb = <>;
+  iommus = < M4U_PORT_HW_VDEC_MC_EXT>,
+ < M4U_PORT_HW_VDEC_PP_EXT>,
+ < M4U_PORT_HW_VDEC_AVC_MV_EXT>,
+ < M4U_PORT_HW_VDEC_PRED_RD_EXT>,
+ < M4U_PORT_HW_VDEC_PRED_WR_EXT>,
+ < M4U_PORT_HW_VDEC_UFO_EXT>,
+ < M4U_PORT_HW_VDEC_VLD_EXT>,
+ < M4U_PORT_HW_VDEC_VLD2_EXT>;
+  mediatek,vpu = <>;
+  power-domains = < MT8173_POWER_DOMAIN_VDEC>;
+  clocks = < CLK_APMIXED_VCODECPLL>,
+ < CLK_TOP_UNIVPLL_D2>,
+ < CLK_TOP_CCI400_SEL>,
+ < CLK_TOP_VDEC_SEL>,
+ < CLK_TOP_VCODECPLL>,
+ < CLK_APMIXED_VENCPLL>,
+ < CLK_TOP_VENC_LT_SEL>,
+ < CLK_TOP_VCODECPLL_370P5>;
+  clock-names = "vcodecpll",
+  "univpll_d2",
+  "clk_cci400_sel",
+  "vdec_sel",
+  "vdecpll",
+ 

[PATCH v14, 03/19] media: mtk-vcodec: Refactor vcodec pm interface

2021-12-14 Thread Yunfei Dong
Using the needed params for pm init/release function and remove unused
param mtkdev in 'struct mtk_vcodec_pm'.

Reviewed-by: Tzung-Bi Shih 
Reviewed-by: AngeloGioacchino Del Regno 

Reviewed-by: Steve Cho 
Signed-off-by: Yunfei Dong 
---
 .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c  |  6 ++---
 .../platform/mtk-vcodec/mtk_vcodec_dec_pm.c   | 22 ---
 .../platform/mtk-vcodec/mtk_vcodec_dec_pm.h   |  5 +++--
 .../platform/mtk-vcodec/mtk_vcodec_drv.h  |  1 -
 .../platform/mtk-vcodec/mtk_vcodec_enc_pm.c   |  1 -
 5 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
index 055d50e52720..3ac4c3935e4e 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
@@ -249,7 +249,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
if (IS_ERR(dev->fw_handler))
return PTR_ERR(dev->fw_handler);
 
-   ret = mtk_vcodec_init_dec_pm(dev);
+   ret = mtk_vcodec_init_dec_pm(dev->plat_dev, >pm);
if (ret < 0) {
dev_err(>dev, "Failed to get mt vcodec clock source");
goto err_dec_pm;
@@ -378,7 +378,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
 err_dec_alloc:
v4l2_device_unregister(>v4l2_dev);
 err_res:
-   mtk_vcodec_release_dec_pm(dev);
+   mtk_vcodec_release_dec_pm(>pm);
 err_dec_pm:
mtk_vcodec_fw_release(dev->fw_handler);
return ret;
@@ -418,7 +418,7 @@ static int mtk_vcodec_dec_remove(struct platform_device 
*pdev)
video_unregister_device(dev->vfd_dec);
 
v4l2_device_unregister(>v4l2_dev);
-   mtk_vcodec_release_dec_pm(dev);
+   mtk_vcodec_release_dec_pm(>pm);
mtk_vcodec_fw_release(dev->fw_handler);
return 0;
 }
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
index 6038db96f71c..20bd157a855c 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
@@ -13,18 +13,15 @@
 #include "mtk_vcodec_dec_pm.h"
 #include "mtk_vcodec_util.h"
 
-int mtk_vcodec_init_dec_pm(struct mtk_vcodec_dev *mtkdev)
+int mtk_vcodec_init_dec_pm(struct platform_device *pdev,
+   struct mtk_vcodec_pm *pm)
 {
struct device_node *node;
-   struct platform_device *pdev;
-   struct mtk_vcodec_pm *pm;
+   struct platform_device *larb_pdev;
struct mtk_vcodec_clk *dec_clk;
struct mtk_vcodec_clk_info *clk_info;
int i = 0, ret = 0;
 
-   pdev = mtkdev->plat_dev;
-   pm = >pm;
-   pm->mtkdev = mtkdev;
dec_clk = >vdec_clk;
node = of_parse_phandle(pdev->dev.of_node, "mediatek,larb", 0);
if (!node) {
@@ -32,13 +29,12 @@ int mtk_vcodec_init_dec_pm(struct mtk_vcodec_dev *mtkdev)
return -1;
}
 
-   pdev = of_find_device_by_node(node);
+   larb_pdev = of_find_device_by_node(node);
of_node_put(node);
-   if (WARN_ON(!pdev)) {
+   if (WARN_ON(!larb_pdev)) {
return -1;
}
-   pm->larbvdec = >dev;
-   pdev = mtkdev->plat_dev;
+   pm->larbvdec = _pdev->dev;
pm->dev = >dev;
 
dec_clk->clk_num =
@@ -82,10 +78,10 @@ int mtk_vcodec_init_dec_pm(struct mtk_vcodec_dev *mtkdev)
return ret;
 }
 
-void mtk_vcodec_release_dec_pm(struct mtk_vcodec_dev *dev)
+void mtk_vcodec_release_dec_pm(struct mtk_vcodec_pm *pm)
 {
-   pm_runtime_disable(dev->pm.dev);
-   put_device(dev->pm.larbvdec);
+   pm_runtime_disable(pm->dev);
+   put_device(pm->larbvdec);
 }
 
 int mtk_vcodec_dec_pw_on(struct mtk_vcodec_pm *pm)
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h
index 280aeaefdb65..a3df6aef6cb9 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h
@@ -9,8 +9,9 @@
 
 #include "mtk_vcodec_drv.h"
 
-int mtk_vcodec_init_dec_pm(struct mtk_vcodec_dev *dev);
-void mtk_vcodec_release_dec_pm(struct mtk_vcodec_dev *dev);
+int mtk_vcodec_init_dec_pm(struct platform_device *pdev,
+   struct mtk_vcodec_pm *pm);
+void mtk_vcodec_release_dec_pm(struct mtk_vcodec_pm *pm);
 
 int mtk_vcodec_dec_pw_on(struct mtk_vcodec_pm *pm);
 void mtk_vcodec_dec_pw_off(struct mtk_vcodec_pm *pm);
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
index 1d2370608d0d..0fa9d85114b9 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
@@ -195,7 +195,6 @@ struct mtk_vcodec_pm {
struct mtk_vcodec_clk   venc_clk;
struct device   *larbvenc;
struct device   *dev;
-   struct mtk_vcodec_dev   *mtkdev;
 

[PATCH v14, 05/19] media: mtk-vcodec: Support MT8192

2021-12-14 Thread Yunfei Dong
From: Yunfei Dong 

Adds MT8192's compatible "mediatek,mt8192-vcodec-dec".
Adds MT8192's device private data mtk_lat_sig_core_pdata.

Reviewed-by: AngeloGioacchino Del Regno 

Signed-off-by: Yunfei Dong 
---
 .../media/platform/mtk-vcodec/mtk_vcodec_dec.h   |  1 +
 .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c |  4 
 .../mtk-vcodec/mtk_vcodec_dec_stateless.c| 16 
 3 files changed, 21 insertions(+)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
index 46783516b84a..e30806c1faea 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.h
@@ -67,6 +67,7 @@ extern const struct v4l2_m2m_ops mtk_vdec_m2m_ops;
 extern const struct media_device_ops mtk_vcodec_media_ops;
 extern const struct mtk_vcodec_dec_pdata mtk_vdec_8173_pdata;
 extern const struct mtk_vcodec_dec_pdata mtk_vdec_8183_pdata;
+extern const struct mtk_vcodec_dec_pdata mtk_lat_sig_core_pdata;
 
 
 /*
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
index 3ac4c3935e4e..b7a51e96d4ba 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
@@ -393,6 +393,10 @@ static const struct of_device_id mtk_vcodec_match[] = {
.compatible = "mediatek,mt8183-vcodec-dec",
.data = _vdec_8183_pdata,
},
+   {
+   .compatible = "mediatek,mt8192-vcodec-dec",
+   .data = _lat_sig_core_pdata,
+   },
{},
 };
 
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c
index 8f4a1f0a0769..26e4d6f4ec04 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_stateless.c
@@ -358,3 +358,19 @@ const struct mtk_vcodec_dec_pdata mtk_vdec_8183_pdata = {
.worker = mtk_vdec_worker,
.flush_decoder = mtk_vdec_flush_decoder,
 };
+
+const struct mtk_vcodec_dec_pdata mtk_lat_sig_core_pdata = {
+   .chip = MTK_MT8192,
+   .init_vdec_params = mtk_init_vdec_params,
+   .ctrls_setup = mtk_vcodec_dec_ctrls_setup,
+   .vdec_vb2_ops = _vdec_request_vb2_ops,
+   .vdec_formats = mtk_video_formats,
+   .num_formats = NUM_FORMATS,
+   .default_out_fmt = _video_formats[DEFAULT_OUT_FMT_IDX],
+   .default_cap_fmt = _video_formats[DEFAULT_CAP_FMT_IDX],
+   .vdec_framesizes = mtk_vdec_framesizes,
+   .num_framesizes = NUM_SUPPORTED_FRAMESIZE,
+   .uses_stateless_api = true,
+   .worker = mtk_vdec_worker,
+   .flush_decoder = mtk_vdec_flush_decoder,
+};
-- 
2.25.1



[PATCH v14, 04/19] media: mtk-vcodec: export decoder pm functions

2021-12-14 Thread Yunfei Dong
When mtk vcodec decoder is build as a module, we need to export
mtk-vcodec-dec pm functions to make them visible by the other components.

Reviewed-by: AngeloGioacchino Del Regno 

Reviewed-by: Benjamin Gaignard 
Signed-off-by: Yunfei Dong 
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
index 20bd157a855c..221cf60e9fbf 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c
@@ -77,12 +77,14 @@ int mtk_vcodec_init_dec_pm(struct platform_device *pdev,
put_device(pm->larbvdec);
return ret;
 }
+EXPORT_SYMBOL_GPL(mtk_vcodec_init_dec_pm);
 
 void mtk_vcodec_release_dec_pm(struct mtk_vcodec_pm *pm)
 {
pm_runtime_disable(pm->dev);
put_device(pm->larbvdec);
 }
+EXPORT_SYMBOL_GPL(mtk_vcodec_release_dec_pm);
 
 int mtk_vcodec_dec_pw_on(struct mtk_vcodec_pm *pm)
 {
@@ -94,6 +96,7 @@ int mtk_vcodec_dec_pw_on(struct mtk_vcodec_pm *pm)
 
return ret;
 }
+EXPORT_SYMBOL_GPL(mtk_vcodec_dec_pw_on);
 
 void mtk_vcodec_dec_pw_off(struct mtk_vcodec_pm *pm)
 {
@@ -103,6 +106,7 @@ void mtk_vcodec_dec_pw_off(struct mtk_vcodec_pm *pm)
if (ret)
mtk_v4l2_err("pm_runtime_put_sync fail %d", ret);
 }
+EXPORT_SYMBOL_GPL(mtk_vcodec_dec_pw_off);
 
 void mtk_vcodec_dec_clock_on(struct mtk_vcodec_pm *pm)
 {
@@ -129,6 +133,7 @@ void mtk_vcodec_dec_clock_on(struct mtk_vcodec_pm *pm)
for (i -= 1; i >= 0; i--)
clk_disable_unprepare(dec_clk->clk_info[i].vcodec_clk);
 }
+EXPORT_SYMBOL_GPL(mtk_vcodec_dec_clock_on);
 
 void mtk_vcodec_dec_clock_off(struct mtk_vcodec_pm *pm)
 {
@@ -139,3 +144,4 @@ void mtk_vcodec_dec_clock_off(struct mtk_vcodec_pm *pm)
for (i = dec_clk->clk_num - 1; i >= 0; i--)
clk_disable_unprepare(dec_clk->clk_info[i].vcodec_clk);
 }
+EXPORT_SYMBOL_GPL(mtk_vcodec_dec_clock_off);
-- 
2.25.1



[PATCH v14, 02/19] media: mtk-vcodec: Align vcodec wake up interrupt interface

2021-12-14 Thread Yunfei Dong
Vdec and venc can use the same function to wake up interrupt event.

Reviewed-by: Tzung-Bi Shih 
Reviewed-by: AngeloGioacchino Del Regno 

Reviewed-by: Steve Cho 
Signed-off-by: Yunfei Dong 
---
 drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 9 +
 drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h | 8 
 drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c | 8 
 3 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
index 59caf2163349..055d50e52720 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
@@ -31,13 +31,6 @@
 module_param(mtk_v4l2_dbg_level, int, 0644);
 module_param(mtk_vcodec_dbg, bool, 0644);
 
-/* Wake up context wait_queue */
-static void wake_up_ctx(struct mtk_vcodec_ctx *ctx)
-{
-   ctx->int_cond = 1;
-   wake_up_interruptible(>queue);
-}
-
 static irqreturn_t mtk_vcodec_dec_irq_handler(int irq, void *priv)
 {
struct mtk_vcodec_dev *dev = priv;
@@ -69,7 +62,7 @@ static irqreturn_t mtk_vcodec_dec_irq_handler(int irq, void 
*priv)
writel((readl(vdec_misc_addr) & ~VDEC_IRQ_CLR),
dev->reg_base[VDEC_MISC] + VDEC_IRQ_CFG_REG);
 
-   wake_up_ctx(ctx);
+   wake_up_ctx(ctx, MTK_INST_IRQ_RECEIVED);
 
mtk_v4l2_debug(3,
"mtk_vcodec_dec_irq_handler :wake up ctx %d, 
dec_done_status=%x",
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
index 581522177308..1d2370608d0d 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h
@@ -473,4 +473,12 @@ static inline struct mtk_vcodec_ctx *ctrl_to_ctx(struct 
v4l2_ctrl *ctrl)
return container_of(ctrl->handler, struct mtk_vcodec_ctx, ctrl_hdl);
 }
 
+/* Wake up context wait_queue */
+static inline void wake_up_ctx(struct mtk_vcodec_ctx *ctx, unsigned int reason)
+{
+   ctx->int_cond = 1;
+   ctx->int_type = reason;
+   wake_up_interruptible(>queue);
+}
+
 #endif /* _MTK_VCODEC_DRV_H_ */
diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
index eed67394cf46..7c3487fb3498 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc_drv.c
@@ -65,14 +65,6 @@ static const struct mtk_video_fmt 
mtk_video_formats_capture_vp8[] =  {
},
 };
 
-/* Wake up context wait_queue */
-static void wake_up_ctx(struct mtk_vcodec_ctx *ctx, unsigned int reason)
-{
-   ctx->int_cond = 1;
-   ctx->int_type = reason;
-   wake_up_interruptible(>queue);
-}
-
 static void clean_irq_status(unsigned int irq_status, void __iomem *addr)
 {
if (irq_status & MTK_VENC_IRQ_STATUS_PAUSE)
-- 
2.25.1



[PATCH v14, 01/19] media: mtk-vcodec: Get numbers of register bases from DT

2021-12-14 Thread Yunfei Dong
Different platforms may have different numbers of register bases. Gets the
numbers of register bases from dts (sizeof(u32) * 4 bytes for each).

Reviewed-by: Tzung-Bi Shih
Signed-off-by: Yunfei Dong 
---
 .../platform/mtk-vcodec/mtk_vcodec_dec_drv.c  | 37 ++-
 1 file changed, 28 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c 
b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
index e6e6a8203eeb..59caf2163349 100644
--- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
+++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c
@@ -78,6 +78,30 @@ static irqreturn_t mtk_vcodec_dec_irq_handler(int irq, void 
*priv)
return IRQ_HANDLED;
 }
 
+static int mtk_vcodec_get_reg_bases(struct mtk_vcodec_dev *dev)
+{
+   struct platform_device *pdev = dev->plat_dev;
+   int reg_num, i;
+
+   /* Sizeof(u32) * 4 bytes for each register base. */
+   reg_num = of_property_count_elems_of_size(pdev->dev.of_node, "reg",
+   sizeof(u32) * 4);
+   if (reg_num <= 0 || reg_num > NUM_MAX_VDEC_REG_BASE) {
+   dev_err(>dev, "Invalid register property size: %d\n", 
reg_num);
+   return -EINVAL;
+   }
+
+   for (i = 0; i < reg_num; i++) {
+   dev->reg_base[i] = devm_platform_ioremap_resource(pdev, i);
+   if (IS_ERR(dev->reg_base[i]))
+   return PTR_ERR(dev->reg_base[i]);
+
+   mtk_v4l2_debug(2, "reg[%d] base=%p", i, dev->reg_base[i]);
+   }
+
+   return 0;
+}
+
 static int fops_vcodec_open(struct file *file)
 {
struct mtk_vcodec_dev *dev = video_drvdata(file);
@@ -206,7 +230,7 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
struct resource *res;
phandle rproc_phandle;
enum mtk_vcodec_fw_type fw_type;
-   int i, ret;
+   int ret;
 
dev = devm_kzalloc(>dev, sizeof(*dev), GFP_KERNEL);
if (!dev)
@@ -238,14 +262,9 @@ static int mtk_vcodec_probe(struct platform_device *pdev)
goto err_dec_pm;
}
 
-   for (i = 0; i < NUM_MAX_VDEC_REG_BASE; i++) {
-   dev->reg_base[i] = devm_platform_ioremap_resource(pdev, i);
-   if (IS_ERR((__force void *)dev->reg_base[i])) {
-   ret = PTR_ERR((__force void *)dev->reg_base[i]);
-   goto err_res;
-   }
-   mtk_v4l2_debug(2, "reg[%d] base=%p", i, dev->reg_base[i]);
-   }
+   ret = mtk_vcodec_get_reg_bases(dev);
+   if (ret)
+   goto err_res;
 
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (res == NULL) {
-- 
2.25.1



[PATCH v14, 00/19] Support multi hardware decode using of_platform_populate

2021-12-14 Thread Yunfei Dong
This series adds support for multi hardware decode into mtk-vcodec, by first 
adding use
of_platform_populate to manage each hardware information: interrupt, clock, 
register
bases and power. Secondly add core work queue to deal with core hardware 
message,
at the same time, add msg queue for different hardware share messages. Lastly, 
the
architecture of different specs are not the same, using specs type to separate 
them.

This series has been tested with both MT8183 and MT8173. Decoding was working 
for both chips.

Patches 1~3 rewrite get register bases and power on/off interface.
Patches 4 export decoder pm interfaces.
Patches 5 add to support 8192.
Patch 6 support multi hardware.
Patch 7 separate video encoder and decoder document
Patch 8-17 add interfaces to support core hardware.
Patch 18-19 remove mtk_vcodec_release_dec/enc_pm interfaces.
---
changes compared with v13:
- change some function position in case of ko dependency for patch 15.
- add reviewed-by for patch 06/13/15.

changes compared with v12:
- fix comments from rob for patch 15.
- fix comments from steve for 06 and 13.

changes compared with v11:
- fix comments from AngeloGioacchino for patch 09~11/19.
- fix comments from steve for patch 03/19.

changes compared with v10:
- fix comments from tzung-bi for patch 06/19.
- add more detail information for hardware block diagram 15/19

changes compared with v9:
- need not to build ko, just export pm interfaces for patch 04/19.
- fix comments for patch 06/19

changes compared with v8:
- add new patch 18~19 to remove mtk_vcodec_release_de/enc_pm interfaces.
- fix spelling mistakes for patch 17/19
- fix yaml comments for patch 15/19

Changes compared with v7:
- add new patch 4 to build decoder pm file as module
- add new patch 5 to support 8192
- fix comments for patch 6/17
- change some logic for using work queue instead of create thread for core 
hardware decode for patch 10/17
- using work queue for hardware decode instead of create thread for patch 13/17
- add returen value for patch 14/17
- fix yaml check fail 15/17

Changes compared with v6:
- Use of_platform_populate to manage multi hardware, not component framework 
for patch 4/15
- Re-write dtsi document for hardware architecture changed for patch 13/15 -The 
dtsi will write like below in patch 13/15:
vcodec_dec: vcodec_dec@1600 {
compatible = "mediatek,mt8192-vcodec-dec";
#address-cells = <2>;
#size-cells = <2>;
ranges;
reg = <0 0x1600 0 0x1000>;  /* VDEC_SYS */
mediatek,scp = <>;
iommus = < M4U_PORT_L4_VDEC_MC_EXT>;
dma-ranges = <0x1 0x0 0x0 0x4000 0x0 0xfff0>;
vcodec_lat {
compatible = "mediatek,mtk-vcodec-lat";
reg = <0 0x1601 0 0x800>;   /* VDEC_MISC */
reg-name = "reg-misc";
interrupts = ;
iommus = < M4U_PORT_L5_VDEC_LAT0_VLD_EXT>,
 < M4U_PORT_L5_VDEC_LAT0_VLD2_EXT>,
 < M4U_PORT_L5_VDEC_LAT0_AVC_MV_EXT>,
 < M4U_PORT_L5_VDEC_LAT0_PRED_RD_EXT>,
 < M4U_PORT_L5_VDEC_LAT0_TILE_EXT>,
 < M4U_PORT_L5_VDEC_LAT0_WDMA_EXT>,
 < M4U_PORT_L5_VDEC_LAT0_RG_CTRL_DMA_EXT>,
 < M4U_PORT_L5_VDEC_UFO_ENC_EXT>;
clocks = < CLK_TOP_VDEC_SEL>,
 <_soc CLK_VDEC_SOC_VDEC>,
 <_soc CLK_VDEC_SOC_LAT>,
 <_soc CLK_VDEC_SOC_LARB1>,
 < CLK_TOP_MAINPLL_D4>;
clock-names = "vdec-sel", "vdec-soc-vdec", "vdec-soc-lat",
  "vdec-vdec", "vdec-top";
assigned-clocks = < CLK_TOP_VDEC_SEL>;
assigned-clock-parents = < CLK_TOP_MAINPLL_D4>;
power-domains = < MT8192_POWER_DOMAIN_VDEC>;
};

vcodec_core {
compatible = "mediatek,mtk-vcodec-core";
reg = <0 0x16025000 0 0x1000>;  /* VDEC_CORE_MISC */
reg-names = "reg-misc";
interrupts = ;
iommus = < M4U_PORT_L4_VDEC_MC_EXT>,
 < M4U_PORT_L4_VDEC_UFO_EXT>,
 < M4U_PORT_L4_VDEC_PP_EXT>,
 < M4U_PORT_L4_VDEC_PRED_RD_EXT>,
 < M4U_PORT_L4_VDEC_PRED_WR_EXT>,
 < M4U_PORT_L4_VDEC_PPWRAP_EXT>,
 < M4U_PORT_L4_VDEC_TILE_EXT>,
 < M4U_PORT_L4_VDEC_VLD_EXT>,
 < M4U_PORT_L4_VDEC_VLD2_EXT>,
 < M4U_PORT_L4_VDEC_AVC_MV_EXT>,
 < M4U_PORT_L4_VDEC_RG_CTRL_DMA_EXT>;
clocks = < CLK_TOP_VDEC_SEL>,
 < CLK_VDEC_VDEC>,
 < CLK_VDEC_LAT>,
 < CLK_VDEC_LARB1>,
 < CLK_TOP_MAINPLL_D4>;
clock-names = "vdec-sel", "vdec-soc-vdec", "vdec-soc-lat",
  "vdec-vdec", "vdec-top";
assigned-clocks = < CLK_TOP_VDEC_SEL>;
assigned-clock-parents = < CLK_TOP_MAINPLL_D4>;
power-domains 

RE: [PATCH v2] drm/amdgpu: introduce new amdgpu_fence object to indicate the job embedded fence

2021-12-14 Thread Huang, Ray
[AMD Official Use Only]

Yes, exactly.

AMDGPU_FENCE_FLAG_EMBED_IN_JOB_BIT is the private flag only for amdgpu. Maybe, 
it's cleaner to define another amdgpu_fence_ops which is dedicated for 
job-embedded fence.

Thanks,
Ray

From: Grodzovsky, Andrey  
Sent: Wednesday, December 15, 2021 1:09 AM
To: Huang, Ray ; dri-devel@lists.freedesktop.org; Koenig, 
Christian ; Daniel Vetter ; 
Sumit Semwal 
Cc: Deucher, Alexander ; 
amd-...@lists.freedesktop.org; Liu, Monk ; 
linux-me...@vger.kernel.org
Subject: Re: [PATCH v2] drm/amdgpu: introduce new amdgpu_fence object to 
indicate the job embedded fence


On 2021-12-14 12:03 p.m., Andrey Grodzovsky wrote:
- 
-    if (job != NULL) { 
-    /* mark this fence has a parent job */ 
-    set_bit(AMDGPU_FENCE_FLAG_EMBED_IN_JOB_BIT, >flags); 
+    if (job) 
+    dma_fence_init(fence, _job_fence_ops, 
+   >fence_drv.lock, 
+   adev->fence_context + ring->idx, seq); 
+    else 
+    dma_fence_init(fence, _fence_ops, 
+   >fence_drv.lock, 
+   adev->fence_context + ring->idx, seq); 
  } 


It's probably me missing something but why can't we just move setting of 
AMDGPU_FENCE_FLAG_EMBED_IN_JOB_BIT 
to before dma_fence_init here or even into amdgpu_job_alloc instead of all the 
refactoring ? 

Andrey 

My bad, I see now that dma_fence_init just overrides flags to 0 and immediately 
call the trace .
But why then can't we add dma_fence_init_with_flags wrapper to dma-fence ?
Andrey


RE: [PATCH v2] drm/amdgpu: introduce new amdgpu_fence object to indicate the job embedded fence

2021-12-14 Thread Huang, Ray
[AMD Official Use Only]

> -Original Message-
> From: Koenig, Christian 
> Sent: Tuesday, December 14, 2021 8:26 PM
> To: Huang, Ray ; dri-devel@lists.freedesktop.org;
> Daniel Vetter ; Sumit Semwal
> 
> Cc: amd-...@lists.freedesktop.org; linux-me...@vger.kernel.org; Deucher,
> Alexander ; Liu, Monk
> 
> Subject: Re: [PATCH v2] drm/amdgpu: introduce new amdgpu_fence object
> to indicate the job embedded fence
> 
> 
> 
> Am 14.12.21 um 12:15 schrieb Huang Rui:
> > The job embedded fence donesn't initialize the flags at
> > dma_fence_init(). Then we will go a wrong way in
> > amdgpu_fence_get_timeline_name callback and trigger a null pointer
> > panic once we enabled the trace event here. So introduce new
> > amdgpu_fence object to indicate the job embedded fence.
> >
> > [  156.131790] BUG: kernel NULL pointer dereference, address:
> > 02a0 [  156.131804] #PF: supervisor read access in kernel
> > mode [  156.131811] #PF: error_code(0x) - not-present page [
> > 156.131817] PGD 0 P4D 0 [  156.131824] Oops:  [#1] PREEMPT SMP PTI
> > [  156.131832] CPU: 6 PID: 1404 Comm: sdma0 Tainted: G   OE 
> > 5.16.0-
> rc1-custom #1
> > [  156.131842] Hardware name: Gigabyte Technology Co., Ltd.
> > Z170XP-SLI/Z170XP-SLI-CF, BIOS F20 11/04/2016 [  156.131848] RIP:
> > 0010:strlen+0x0/0x20 [  156.131859] Code: 89 c0 c3 0f 1f 80 00 00 00
> > 00 48 01 fe eb 0f 0f b6 07 38 d0 74 10 48 83 c7 01 84 c0 74 05 48 39
> > f7 75 ec 31 c0 c3 48 89 f8 c3 <80> 3f 00 74 10 48 89 f8 48 83 c0 01 80
> > 38 00 75 f7 48 29 f8 c3 31 [  156.131872] RSP: 0018:9bd0018dbcf8
> > EFLAGS: 00010206 [  156.131880] RAX: 02a0 RBX:
> > 8d0305ef01b0 RCX: 000b [  156.131888] RDX:
> > 8d03772ab924 RSI: 8d0305ef01b0 RDI: 02a0 [
> > 156.131895] RBP: 9bd0018dbd60 R08: 8d03002094d0 R09:
> >  [  156.131901] R10: 005e R11:
> > 0065 R12: 8d03002094d0 [  156.131907] R13:
> > 001f R14: 00070018 R15: 0007 [
> > 156.131914] FS:  () GS:8d062ed8()
> > knlGS: [  156.131923] CS:  0010 DS:  ES:  CR0:
> 80050033 [  156.131929] CR2: 02a0 CR3:
> 1120a005 CR4: 003706e0 [  156.131937] DR0:
>  DR1:  DR2: 
> [  156.131942] DR3:  DR6: fffe0ff0 DR7:
> 0400 [  156.131949] Call Trace:
> > [  156.131953]  
> > [  156.131957]  ? trace_event_raw_event_dma_fence+0xcc/0x200
> > [  156.131973]  ? ring_buffer_unlock_commit+0x23/0x130
> > [  156.131982]  dma_fence_init+0x92/0xb0 [  156.131993]
> > amdgpu_fence_emit+0x10d/0x2b0 [amdgpu] [  156.132302]
> > amdgpu_ib_schedule+0x2f9/0x580 [amdgpu] [  156.132586]
> > amdgpu_job_run+0xed/0x220 [amdgpu]
> >
> > Signed-off-by: Huang Rui 
> > ---
> >   drivers/gpu/drm/amd/amdgpu/amdgpu.h|   1 +
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |   3 +-
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c  | 117
> ++---
> >   drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h   |   3 -
> >   4 files changed, 80 insertions(+), 44 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> > index 9f017663ac50..fcaf6e9703f9 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> > @@ -444,6 +444,7 @@ struct amdgpu_sa_bo {
> >
> >   int amdgpu_fence_slab_init(void);
> >   void amdgpu_fence_slab_fini(void);
> > +bool is_job_embedded_fence(struct dma_fence *f);
> 
> We need a better name for this, especially with amdgpu in it. Something like
> is_amdgpu_job_fence().
> 
> But maybe we can avoid that function alltogether, see below.
> 
> >
> >   /*
> >* IRQS.
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > index 5625f7736e37..444a19eb2248 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> > @@ -4483,9 +4483,8 @@ int amdgpu_device_pre_asic_reset(struct
> > amdgpu_device *adev,
> >
> > ptr = >fence_drv.fences[j];
> > old = rcu_dereference_protected(*ptr, 1);
> > -   if (old &&
> test_bit(AMDGPU_FENCE_FLAG_EMBED_IN_JOB_BIT, >flags)) {
> > +   if (old && is_job_embedded_fence(old))
> > RCU_INIT_POINTER(*ptr, NULL);
> > -   }
> 
> This here is messing with the fence internals and so should probably be a
> function in amdgpu_fence.c.
> 
> This way we would have embedded the amdgpu fence in there as well. Apart
> from that looks rather good to me.
> 

So we can create new function in amdgpu_fence.c to implement the job fence 
clearing here and call it here instead.
That is pure job fence operation, so we won't need to put it in amdgpu_device.c.

Thanks,
Ray

> Christian.

Re: [PATCH v3 0/7] drm: exynos: dsi: Convert drm bridge

2021-12-14 Thread Marek Szyprowski
Hi Jagan,

On 14.12.2021 11:47, Jagan Teki wrote:
> On Mon, Dec 13, 2021 at 7:42 PM Marek Szyprowski
>  wrote:
>> On 13.12.2021 14:56, Jagan Teki wrote:
>>> On Mon, Dec 13, 2021 at 6:51 PM Marek Szyprowski
>>>  wrote:
 On 13.12.2021 13:31, Jagan Teki wrote:
> On Mon, Dec 13, 2021 at 5:42 PM Marek Szyprowski
>  wrote:
>> On 13.12.2021 13:08, Jagan Teki wrote:
>>> On Mon, Dec 13, 2021 at 5:34 PM Marek Szyprowski
>>>  wrote:
 On 12.12.2021 19:14, Jagan Teki wrote:
> Updated series about drm bridge conversion of exynos dsi.
>
> Patch 1: panel checker
>
> Patch 2: panel_bridge API
>
> Patch 3: Bridge conversion
>
> Patch 4: pree_enable, post_disable
>
> Patch 5: Atomic functions
>
> Patch 6: atomic_set
>
> Patch 7: DSI init in enable
>
> [1] 
> https://patchwork.kernel.org/project/dri-devel/cover/20211210191922.2367979-1-ja...@amarulasolutions.com/
>
> Any inputs?
 I've checked this patchset on Exynos based Trats2 board (the one with
 simplest display pipeline: Exynos FIMD -> Exynos DSI -> s6e8aa0 DSI
 panel). DRM stops working after the 2nd patch ("[PATCH v3 2/7] drm:
 exynos: dsi: Use drm panel_bridge API"):

 > [...]
>>> Thanks for testing it.
>>>
>>> Can you test it on the downstream bridge, tc358764 and post the result?
>> There were 2 logs in my reply. One from trats2 board (just dsi panel)
>> and one from arndale (tc bridge + simple panel).
> Okay. Got it.
>
> Can you test this tc358764 panel_bridge patch on linux-next? don't
> apply this series, apply only below patch and test.
>
Yes, sure. Sadly, it also breaks display operation:

OF: graph: no port node found in /soc/hdmi@1453
[drm] Exynos DRM: using 1440.fimd device for DMA mapping operations
exynos-drm exynos-drm: bound 1440.fimd (ops fimd_component_ops)
exynos-drm exynos-drm: bound 1445.mixer (ops mixer_component_ops)
OF: graph: no port node found in /soc/dsi@1450
exynos-drm exynos-drm: bound 1450.dsi (ops exynos_dsi_component_ops)
exynos-drm exynos-drm: bound 1453.hdmi (ops hdmi_component_ops)
exynos-drm exynos-drm: [drm] Cannot find any crtc or sizes
exynos-drm exynos-drm: [drm] Cannot find any crtc or sizes
[drm] Initialized exynos 1.1.0 20180330 for exynos-drm on minor 0
panfrost 1180.gpu: clock rate = 53300
panfrost 1180.gpu: mali-t600 id 0x600 major 0x0 minor 0x0 status 0x1
panfrost 1180.gpu: features: ,10206000, issues: 
,31b4dfff
panfrost 1180.gpu: Features: L2:0x07110206 Shader:0x 
Tiler:0x0809 Mem:0x1 MMU:0x2830 AS:0xf JS:0x7
panfrost 1180.gpu: shader_present=0xf l2_present=0x1
[drm] Initialized panfrost 1.2.0 20180908 for 1180.gpu on minor 1
[ cut here ]
WARNING: CPU: 1 PID: 23 at drivers/gpu/drm/drm_atomic_state_helper.c:494 
drm_atomic_helper_connector_duplicate_state+0x60/0x68
Modules linked in:
CPU: 1 PID: 23 Comm: kworker/1:1 Not tainted 
5.16.0-rc5-next-20211213-1-gac4117943791 #11072
Hardware name: Samsung Exynos (Flattened Device Tree)
Workqueue: events output_poll_execute
[] (unwind_backtrace) from [] (show_stack+0x10/0x14)
[] (show_stack) from [] (dump_stack_lvl+0x58/0x70)
[] (dump_stack_lvl) from [] (__warn+0x228/0x22c)
[] (__warn) from [] (warn_slowpath_fmt+0xac/0xb4)
[] (warn_slowpath_fmt) from [] 
(drm_atomic_helper_connector_duplicate_state+0x60/0x68)
[] (drm_atomic_helper_connector_duplicate_state) from 
[] (drm_atomic_get_connector_state+0xd8/0x190)
[] (drm_atomic_get_connector_state) from [] 
(__drm_atomic_helper_set_config+0x2a0/0x368)
[] (__drm_atomic_helper_set_config) from [] 
(drm_client_modeset_commit_atomic+0x178/0x27c)
[] (drm_client_modeset_commit_atomic) from [] 
(drm_client_modeset_commit_locked+0x48/0x1d0)
[] (drm_client_modeset_commit_locked) from [] 
(drm_client_modeset_commit+0x24/0x40)
[] (drm_client_modeset_commit) from [] 
(__drm_fb_helper_restore_fbdev_mode_unlocked+0x64/0xc8)
[] (__drm_fb_helper_restore_fbdev_mode_unlocked) from 
[] (drm_fb_helper_set_par+0x38/0x64)
[] (drm_fb_helper_set_par) from [] 
(drm_fb_helper_hotplug_event.part.5+0xa8/0xc0)
[] (drm_fb_helper_hotplug_event.part.5) from [] 
(drm_kms_helper_hotplug_event+0x24/0x30)
[] (drm_kms_helper_hotplug_event) from [] 
(output_poll_execute+0x1ec/0x204)
[] (output_poll_execute) from [] 
(process_one_work+0x2c8/0x7ec)
[] (process_one_work) from [] (worker_thread+0x50/0x584)
[] (worker_thread) from [] (kthread+0x13c/0x19c)
[] (kthread) from [] (ret_from_fork+0x14/0x2c)
Exception stack(0xc1d35fb0 to 0xc1d35ff8)
5fa0:    

5fc0:        

5fe0:     0013 
irq event stamp: 1287
hardirqs last  enabled at (1293): [] 

[PATCH -next] drm/omap: Fix NULL but dereferenced coccicheck error

2021-12-14 Thread Yang Li
Eliminate the following coccicheck warning:
./drivers/gpu/drm/omapdrm/omap_overlay.c:89:22-25: ERROR: r_ovl is NULL
but dereferenced.

Reported-by: Abaci Robot 
Fixes: e02b5cc9e898 ("drm/omap: Add a 'right overlay' to plane state")
Signed-off-by: Yang Li 
---
 drivers/gpu/drm/omapdrm/omap_overlay.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_overlay.c 
b/drivers/gpu/drm/omapdrm/omap_overlay.c
index 10730c9b2752..b0bc9ad2ef73 100644
--- a/drivers/gpu/drm/omapdrm/omap_overlay.c
+++ b/drivers/gpu/drm/omapdrm/omap_overlay.c
@@ -86,7 +86,7 @@ int omap_overlay_assign(struct drm_atomic_state *s, struct 
drm_plane *plane,
r_ovl = omap_plane_find_free_overlay(s->dev, overlay_map,
 caps, fourcc);
if (!r_ovl) {
-   overlay_map[r_ovl->idx] = NULL;
+   overlay_map[ovl->idx] = NULL;
*overlay = NULL;
return -ENOMEM;
}
-- 
2.20.1.7.g153144c



Re: [PATCH v7 2/2] drm/msm/dp: do not initialize phy until plugin interrupt received

2021-12-14 Thread Stephen Boyd
Quoting Kuogee Hsieh (2021-12-09 13:35:07)
> diff --git a/drivers/gpu/drm/msm/dp/dp_display.c 
> b/drivers/gpu/drm/msm/dp/dp_display.c
> index 0766752..cfbc5e4 100644
> --- a/drivers/gpu/drm/msm/dp/dp_display.c
> +++ b/drivers/gpu/drm/msm/dp/dp_display.c
> @@ -83,6 +83,7 @@ struct dp_display_private {
>
> /* state variables */
> bool core_initialized;
> +   bool phy_initialized;
> bool hpd_irq_on;
> bool audio_supported;
>
> @@ -371,21 +372,46 @@ static int dp_display_process_hpd_high(struct 
> dp_display_private *dp)
> return rc;
>  }
>
> -static void dp_display_host_init(struct dp_display_private *dp, int reset)
> +static void dp_display_host_phy_init(struct dp_display_private *dp)
>  {
> -   bool flip = false;
> +   DRM_DEBUG_DP("core_init=%d phy_init=%d\n",
> +   dp->core_initialized, dp->phy_initialized);
>
> +   if (!dp->phy_initialized) {

Is this check only here because we don't know when this function is
getting called? I see in the DP case we get here from
dp_display_usbpd_configure_cb() but in the eDP case we get here from
dp_display_host_init() and presumably again from
dp_display_usbpd_configure_cb() called by dp_hpd_plug_handle().

If at all possible, I'd prefer to not have another tracking variable and
call dp_display_host_phy_init() from the same place regardless of DP or
eDP. Doing that would make it symmetric, per the commit text.

> +   dp_ctrl_phy_init(dp->ctrl);
> +   dp->phy_initialized = true;
> +   }
> +}
> +
> +static void dp_display_host_phy_exit(struct dp_display_private *dp)
> +{
> +   DRM_DEBUG_DP("core_init=%d phy_init=%d\n",
> +   dp->core_initialized, dp->phy_initialized);
> +
> +   if (dp->phy_initialized) {
> +   dp_ctrl_phy_exit(dp->ctrl);
> +   dp->phy_initialized = false;
> +   }
> +}
> +
> +static void dp_display_host_init(struct dp_display_private *dp)
> +{
> DRM_DEBUG_DP("core_initialized=%d\n", dp->core_initialized);
> if (dp->core_initialized) {
> DRM_DEBUG_DP("DP core already initialized\n");
> return;
> }
>
> -   if (dp->usbpd->orientation == ORIENTATION_CC2)
> -   flip = true;
> +   dp_power_init(dp->power, false);
> +   dp_ctrl_reset_irq_ctrl(dp->ctrl, true);
> +
> +   /*
> +* eDP is the embedded primary display and has its own phy
> +* initialize phy immediately

Can we get some more details here? Why is it better to initialize the
phy here vs. when HPD goes high on the panel? The comment says what the
code is doing but it isn't telling us why that's OK.

> +*/
> +   if (dp->dp_display.connector_type == DRM_MODE_CONNECTOR_eDP)
> +   dp_display_host_phy_init(dp);
>
> -   dp_power_init(dp->power, flip);
> -   dp_ctrl_host_init(dp->ctrl, flip, reset);
> dp_aux_init(dp->aux);
> dp->core_initialized = true;
>  }


Re: [PATCH 56/60] drm/tve200: Add support for the nomodeset kernel parameter

2021-12-14 Thread Linus Walleij
On Wed, Dec 15, 2021 at 2:01 AM Javier Martinez Canillas
 wrote:

> According to disable Documentation/admin-guide/kernel-parameters.txt, this
> parameter can be used to disable kernel modesetting.
>
> DRM drivers will not perform display-mode changes or accelerated rendering
> and only the systewm system framebuffer will be available if it was set-up.
>
> But only a few DRM drivers currently check for nomodeset, make this driver
> to also support the command line parameter.
>
> Signed-off-by: Javier Martinez Canillas 

Reviewed-by: Linus Walleij 

Yours,
Linus Walleij


Re: [PATCH 21/60] drm/mcde: Add support for the nomodeset kernel parameter

2021-12-14 Thread Linus Walleij
On Wed, Dec 15, 2021 at 2:01 AM Javier Martinez Canillas
 wrote:

> According to disable Documentation/admin-guide/kernel-parameters.txt, this
> parameter can be used to disable kernel modesetting.
>
> DRM drivers will not perform display-mode changes or accelerated rendering
> and only the systewm system framebuffer will be available if it was set-up.
>
> But only a few DRM drivers currently check for nomodeset, make this driver
> to also support the command line parameter.
>
> Signed-off-by: Javier Martinez Canillas 

Reviewed-by: Linus Walleij 

Yours,
Linus Walleij


[PATCH 36/60] drm/sis: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/sis/sis_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/sis/sis_drv.c b/drivers/gpu/drm/sis/sis_drv.c
index e35e719cf315..d592af70e8be 100644
--- a/drivers/gpu/drm/sis/sis_drv.c
+++ b/drivers/gpu/drm/sis/sis_drv.c
@@ -126,6 +126,9 @@ static struct pci_driver sis_pci_driver = {
 
 static int __init sis_init(void)
 {
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
driver.num_ioctls = sis_max_ioctl;
return drm_legacy_pci_init(, _pci_driver);
 }
-- 
2.33.1



[PATCH 46/60] drm/gm12u320: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/tiny/gm12u320.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/tiny/gm12u320.c b/drivers/gpu/drm/tiny/gm12u320.c
index 6bc0c298739c..b9a5f4969337 100644
--- a/drivers/gpu/drm/tiny/gm12u320.c
+++ b/drivers/gpu/drm/tiny/gm12u320.c
@@ -636,6 +636,9 @@ static int gm12u320_usb_probe(struct usb_interface 
*interface,
struct drm_device *dev;
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
/*
 * The gm12u320 presents itself to the system as 2 usb mass-storage
 * interfaces, we only care about / need the first one.
-- 
2.33.1



[PATCH 41/60] drm/tdfx: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/tdfx/tdfx_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/tdfx/tdfx_drv.c b/drivers/gpu/drm/tdfx/tdfx_drv.c
index 58c185c299f4..d0ae79ad437f 100644
--- a/drivers/gpu/drm/tdfx/tdfx_drv.c
+++ b/drivers/gpu/drm/tdfx/tdfx_drv.c
@@ -74,6 +74,9 @@ static struct pci_driver tdfx_pci_driver = {
 
 static int __init tdfx_init(void)
 {
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
return drm_legacy_pci_init(, _pci_driver);
 }
 
-- 
2.33.1



[PATCH 40/60] drm/sun4i: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/sun4i/sun4i_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c 
b/drivers/gpu/drm/sun4i/sun4i_drv.c
index b630614b3d72..174d3d7790e6 100644
--- a/drivers/gpu/drm/sun4i/sun4i_drv.c
+++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
@@ -373,6 +373,9 @@ static int sun4i_drv_probe(struct platform_device *pdev)
struct endpoint_list list;
int i, ret, count = 0;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
INIT_KFIFO(list.fifo);
 
for (i = 0;; i++) {
-- 
2.33.1



[PATCH 51/60] drm/ili9486: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/tiny/ili9486.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/tiny/ili9486.c b/drivers/gpu/drm/tiny/ili9486.c
index e9a63f4b2993..8e46420e1a87 100644
--- a/drivers/gpu/drm/tiny/ili9486.c
+++ b/drivers/gpu/drm/tiny/ili9486.c
@@ -196,6 +196,9 @@ static int ili9486_probe(struct spi_device *spi)
u32 rotation = 0;
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
dbidev = devm_drm_dev_alloc(dev, _driver,
struct mipi_dbi_dev, drm);
if (IS_ERR(dbidev))
-- 
2.33.1



[PATCH 45/60] drm/arc: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/tiny/arcpgu.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/tiny/arcpgu.c b/drivers/gpu/drm/tiny/arcpgu.c
index f8531c50a072..9268f37762c8 100644
--- a/drivers/gpu/drm/tiny/arcpgu.c
+++ b/drivers/gpu/drm/tiny/arcpgu.c
@@ -378,6 +378,9 @@ static int arcpgu_probe(struct platform_device *pdev)
struct arcpgu_drm_private *arcpgu;
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
arcpgu = devm_drm_dev_alloc(>dev, _drm_driver,
struct arcpgu_drm_private, drm);
if (IS_ERR(arcpgu))
-- 
2.33.1



[PATCH 52/60] drm/mi0283qt: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/tiny/mi0283qt.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/tiny/mi0283qt.c b/drivers/gpu/drm/tiny/mi0283qt.c
index 023de49e7a8e..f96fd350d373 100644
--- a/drivers/gpu/drm/tiny/mi0283qt.c
+++ b/drivers/gpu/drm/tiny/mi0283qt.c
@@ -186,6 +186,9 @@ static int mi0283qt_probe(struct spi_device *spi)
u32 rotation = 0;
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
dbidev = devm_drm_dev_alloc(dev, _driver,
struct mipi_dbi_dev, drm);
if (IS_ERR(dbidev))
-- 
2.33.1



[PATCH 28/60] drm/panel: ilitek-ili9341: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/panel/panel-ilitek-ili9341.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/panel/panel-ilitek-ili9341.c 
b/drivers/gpu/drm/panel/panel-ilitek-ili9341.c
index 2c3378a259b1..707c5a7bf256 100644
--- a/drivers/gpu/drm/panel/panel-ilitek-ili9341.c
+++ b/drivers/gpu/drm/panel/panel-ilitek-ili9341.c
@@ -611,6 +611,9 @@ static int ili9341_dbi_probe(struct spi_device *spi, struct 
gpio_desc *dc,
u32 rotation = 0;
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
vcc = devm_regulator_get_optional(dev, "vcc");
if (IS_ERR(vcc))
dev_err(dev, "get optional vcc failed\n");
-- 
2.33.1



[PATCH 57/60] drm/udl: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/udl/udl_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
index 5703277c6f52..d5a0aa762ec8 100644
--- a/drivers/gpu/drm/udl/udl_drv.c
+++ b/drivers/gpu/drm/udl/udl_drv.c
@@ -91,6 +91,9 @@ static int udl_usb_probe(struct usb_interface *interface,
int r;
struct udl_device *udl;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
udl = udl_driver_create(interface);
if (IS_ERR(udl))
return PTR_ERR(udl);
-- 
2.33.1



[PATCH 33/60] drm/rockchip: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c 
b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index bec207de4544..ac190e2b1f7a 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -457,6 +457,9 @@ static int __init rockchip_drm_init(void)
 {
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
num_rockchip_sub_drivers = 0;
ADD_ROCKCHIP_SUB_DRIVER(vop_platform_driver, CONFIG_DRM_ROCKCHIP);
ADD_ROCKCHIP_SUB_DRIVER(rockchip_lvds_driver,
-- 
2.33.1



[PATCH 25/60] drm/msm: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/msm/msm_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 7936e8d498dd..eb098475224b 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -518,6 +518,9 @@ static int msm_drm_init(struct device *dev, const struct 
drm_driver *drv)
struct msm_mdss *mdss;
int ret, i;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
ddev = drm_dev_alloc(drv, dev);
if (IS_ERR(ddev)) {
DRM_DEV_ERROR(dev, "failed to allocate drm_device\n");
-- 
2.33.1



[PATCH 58/60] drm/via: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/via/via_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/via/via_drv.c b/drivers/gpu/drm/via/via_drv.c
index 5da38082821f..57d63514f812 100644
--- a/drivers/gpu/drm/via/via_drv.c
+++ b/drivers/gpu/drm/via/via_drv.c
@@ -106,6 +106,9 @@ static struct pci_driver via_pci_driver = {
 
 static int __init via_init(void)
 {
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
driver.num_ioctls = via_max_ioctl;
via_init_command_verifier();
return drm_legacy_pci_init(, _pci_driver);
-- 
2.33.1



[PATCH 47/60] drm/hx8357d: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/tiny/hx8357d.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/tiny/hx8357d.c b/drivers/gpu/drm/tiny/hx8357d.c
index 9b33c05732aa..fd788d36efdd 100644
--- a/drivers/gpu/drm/tiny/hx8357d.c
+++ b/drivers/gpu/drm/tiny/hx8357d.c
@@ -225,6 +225,9 @@ static int hx8357d_probe(struct spi_device *spi)
u32 rotation = 0;
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
dbidev = devm_drm_dev_alloc(dev, _driver,
struct mipi_dbi_dev, drm);
if (IS_ERR(dbidev))
-- 
2.33.1



[PATCH 44/60] drm/tilcdc: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/tilcdc/tilcdc_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c 
b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 3ddb7c710a3d..25fe1f8de6bd 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -606,6 +606,9 @@ static struct platform_driver tilcdc_platform_driver = {
 
 static int __init tilcdc_drm_init(void)
 {
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
DBG("init");
tilcdc_panel_init();
return platform_driver_register(_platform_driver);
-- 
2.33.1



[PATCH 27/60] drm/omap: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/omapdrm/omap_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index 2720a58ccd90..eaf67b9e5f12 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -727,6 +727,9 @@ static int omapdrm_init(struct omap_drm_private *priv, 
struct device *dev)
 
DBG("%s", dev_name(dev));
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
/* Allocate and initialize the DRM device. */
ddev = drm_dev_alloc(_drm_driver, dev);
if (IS_ERR(ddev))
-- 
2.33.1



[PATCH 54/60] drm/st7586: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/tiny/st7586.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/tiny/st7586.c b/drivers/gpu/drm/tiny/st7586.c
index 51b9b9fb3ead..55bf695861c7 100644
--- a/drivers/gpu/drm/tiny/st7586.c
+++ b/drivers/gpu/drm/tiny/st7586.c
@@ -305,6 +305,9 @@ static int st7586_probe(struct spi_device *spi)
size_t bufsize;
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
dbidev = devm_drm_dev_alloc(dev, _driver,
struct mipi_dbi_dev, drm);
if (IS_ERR(dbidev))
-- 
2.33.1



[PATCH 60/60] drm/xlnx: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/xlnx/zynqmp_dpsub.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/xlnx/zynqmp_dpsub.c 
b/drivers/gpu/drm/xlnx/zynqmp_dpsub.c
index ac37053412a1..cca55b8a8cf1 100644
--- a/drivers/gpu/drm/xlnx/zynqmp_dpsub.c
+++ b/drivers/gpu/drm/xlnx/zynqmp_dpsub.c
@@ -191,6 +191,9 @@ static int zynqmp_dpsub_probe(struct platform_device *pdev)
struct zynqmp_dpsub *dpsub;
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
/* Allocate private data. */
dpsub = devm_drm_dev_alloc(>dev, _dpsub_drm_driver,
   struct zynqmp_dpsub, drm);
-- 
2.33.1



[PATCH 49/60] drm/ili9225: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/tiny/ili9225.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/tiny/ili9225.c b/drivers/gpu/drm/tiny/ili9225.c
index 976d3209f164..1d193c534318 100644
--- a/drivers/gpu/drm/tiny/ili9225.c
+++ b/drivers/gpu/drm/tiny/ili9225.c
@@ -369,6 +369,9 @@ static int ili9225_probe(struct spi_device *spi)
u32 rotation = 0;
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
dbidev = devm_drm_dev_alloc(dev, _driver,
struct mipi_dbi_dev, drm);
if (IS_ERR(dbidev))
-- 
2.33.1



[PATCH 50/60] drm/ili9341: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/tiny/ili9341.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/tiny/ili9341.c b/drivers/gpu/drm/tiny/ili9341.c
index 37e0c33399c8..5226b768c550 100644
--- a/drivers/gpu/drm/tiny/ili9341.c
+++ b/drivers/gpu/drm/tiny/ili9341.c
@@ -182,6 +182,9 @@ static int ili9341_probe(struct spi_device *spi)
u32 rotation = 0;
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
dbidev = devm_drm_dev_alloc(dev, _driver,
struct mipi_dbi_dev, drm);
if (IS_ERR(dbidev))
-- 
2.33.1



[PATCH 18/60] drm/ingenic: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c 
b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
index b4943a56be09..8748cc5d2069 100644
--- a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
+++ b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
@@ -1487,6 +1487,9 @@ static int ingenic_drm_init(void)
 {
int err;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
if (IS_ENABLED(CONFIG_DRM_INGENIC_IPU)) {
err = platform_driver_register(ingenic_ipu_driver_ptr);
if (err)
-- 
2.33.1



[PATCH 59/60] drm/xen: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/xen/xen_drm_front.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/xen/xen_drm_front.c 
b/drivers/gpu/drm/xen/xen_drm_front.c
index 434064c820e8..20d11ea79e0f 100644
--- a/drivers/gpu/drm/xen/xen_drm_front.c
+++ b/drivers/gpu/drm/xen/xen_drm_front.c
@@ -495,6 +495,9 @@ static int xen_drm_drv_init(struct xen_drm_front_info 
*front_info)
struct drm_device *drm_dev;
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
DRM_INFO("Creating %s\n", xen_drm_driver.desc);
 
drm_info = kzalloc(sizeof(*drm_info), GFP_KERNEL);
-- 
2.33.1



[PATCH 26/60] drm: mxsfb: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/mxsfb/mxsfb_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/mxsfb/mxsfb_drv.c 
b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
index 86d78634a979..1359fc99c6f0 100644
--- a/drivers/gpu/drm/mxsfb/mxsfb_drv.c
+++ b/drivers/gpu/drm/mxsfb/mxsfb_drv.c
@@ -342,6 +342,9 @@ static int mxsfb_probe(struct platform_device *pdev)
of_match_device(mxsfb_dt_ids, >dev);
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
if (!pdev->dev.of_node)
return -ENODEV;
 
-- 
2.33.1



[PATCH 32/60] drm: rcar-du: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/rcar-du/rcar_du_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c 
b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index 5612a9e7a905..7b676b2f0f06 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -699,6 +699,9 @@ static struct platform_driver rcar_du_platform_driver = {
 
 static int __init rcar_du_init(void)
 {
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
rcar_du_of_init(rcar_du_of_table);
 
return platform_driver_register(_du_platform_driver);
-- 
2.33.1



[PATCH 55/60] drm/st7735r: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/tiny/st7735r.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/tiny/st7735r.c b/drivers/gpu/drm/tiny/st7735r.c
index fc40dd10efa8..841ec1c7bb93 100644
--- a/drivers/gpu/drm/tiny/st7735r.c
+++ b/drivers/gpu/drm/tiny/st7735r.c
@@ -190,6 +190,9 @@ static int st7735r_probe(struct spi_device *spi)
u32 rotation = 0;
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
cfg = device_get_match_data(>dev);
if (!cfg)
cfg = (void *)spi_get_device_id(spi)->driver_data;
-- 
2.33.1



[PATCH 30/60] drm/pl111: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/pl111/pl111_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/pl111/pl111_drv.c 
b/drivers/gpu/drm/pl111/pl111_drv.c
index 520301b405f1..7a316c8d8301 100644
--- a/drivers/gpu/drm/pl111/pl111_drv.c
+++ b/drivers/gpu/drm/pl111/pl111_drv.c
@@ -243,6 +243,9 @@ static int pl111_amba_probe(struct amba_device *amba_dev,
struct drm_device *drm;
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
-- 
2.33.1



[PATCH 43/60] drm/tidss: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/tidss/tidss_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/tidss/tidss_drv.c 
b/drivers/gpu/drm/tidss/tidss_drv.c
index 7c784e90e40e..5a6ff5af6d26 100644
--- a/drivers/gpu/drm/tidss/tidss_drv.c
+++ b/drivers/gpu/drm/tidss/tidss_drv.c
@@ -124,6 +124,9 @@ static int tidss_probe(struct platform_device *pdev)
 
dev_dbg(dev, "%s\n", __func__);
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
tidss = devm_drm_dev_alloc(>dev, _driver,
   struct tidss_device, ddev);
if (IS_ERR(tidss))
-- 
2.33.1



[PATCH 53/60] drm/repaper: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/tiny/repaper.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/tiny/repaper.c b/drivers/gpu/drm/tiny/repaper.c
index 97a775c48cea..ea97b8c06157 100644
--- a/drivers/gpu/drm/tiny/repaper.c
+++ b/drivers/gpu/drm/tiny/repaper.c
@@ -968,6 +968,9 @@ static int repaper_probe(struct spi_device *spi)
const void *match;
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
match = device_get_match_data(dev);
if (match) {
model = (enum repaper_model)match;
-- 
2.33.1



[PATCH 56/60] drm/tve200: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/tve200/tve200_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/tve200/tve200_drv.c 
b/drivers/gpu/drm/tve200/tve200_drv.c
index 7fa71c8bb828..afa3a2771650 100644
--- a/drivers/gpu/drm/tve200/tve200_drv.c
+++ b/drivers/gpu/drm/tve200/tve200_drv.c
@@ -158,6 +158,9 @@ static int tve200_probe(struct platform_device *pdev)
int irq;
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
-- 
2.33.1



[PATCH 29/60] drm/panfrost: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/panfrost/panfrost_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c 
b/drivers/gpu/drm/panfrost/panfrost_drv.c
index 96bb5a465627..6effe1fdc893 100644
--- a/drivers/gpu/drm/panfrost/panfrost_drv.c
+++ b/drivers/gpu/drm/panfrost/panfrost_drv.c
@@ -547,6 +547,9 @@ static int panfrost_probe(struct platform_device *pdev)
struct drm_device *ddev;
int err;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
pfdev = devm_kzalloc(>dev, sizeof(*pfdev), GFP_KERNEL);
if (!pfdev)
return -ENOMEM;
-- 
2.33.1



[PATCH 39/60] drm/stm: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/stm/drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/stm/drv.c b/drivers/gpu/drm/stm/drv.c
index 222869b232ae..91ac5437fa40 100644
--- a/drivers/gpu/drm/stm/drv.c
+++ b/drivers/gpu/drm/stm/drv.c
@@ -183,6 +183,9 @@ static int stm_drm_platform_probe(struct platform_device 
*pdev)
 
DRM_DEBUG("%s\n", __func__);
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
 
ddev = drm_dev_alloc(_driver, dev);
-- 
2.33.1



[PATCH 19/60] drm/kmb: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/kmb/kmb_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/kmb/kmb_drv.c b/drivers/gpu/drm/kmb/kmb_drv.c
index ed2424350773..56a59ee71755 100644
--- a/drivers/gpu/drm/kmb/kmb_drv.c
+++ b/drivers/gpu/drm/kmb/kmb_drv.c
@@ -484,6 +484,9 @@ static int kmb_probe(struct platform_device *pdev)
struct device_node *dsi_node;
struct platform_device *dsi_pdev;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
/* The bridge (ADV 7535) will return -EPROBE_DEFER until it
 * has a mipi_dsi_host to register its device to. So, we
 * first register the DSI host during probe time, and then return
-- 
2.33.1



[PATCH 34/60] drm/savage: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/savage/savage_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/savage/savage_drv.c 
b/drivers/gpu/drm/savage/savage_drv.c
index 799bd11adb9c..bb3f12874178 100644
--- a/drivers/gpu/drm/savage/savage_drv.c
+++ b/drivers/gpu/drm/savage/savage_drv.c
@@ -74,6 +74,9 @@ static struct pci_driver savage_pci_driver = {
 
 static int __init savage_init(void)
 {
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
driver.num_ioctls = savage_max_ioctl;
return drm_legacy_pci_init(, _pci_driver);
 }
-- 
2.33.1



[PATCH 24/60] drm/mga: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/mga/mga_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/mga/mga_drv.c b/drivers/gpu/drm/mga/mga_drv.c
index 71128e6f6ae9..dc4154d39133 100644
--- a/drivers/gpu/drm/mga/mga_drv.c
+++ b/drivers/gpu/drm/mga/mga_drv.c
@@ -87,6 +87,9 @@ static struct pci_driver mga_pci_driver = {
 
 static int __init mga_init(void)
 {
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
driver.num_ioctls = mga_max_ioctl;
return drm_legacy_pci_init(, _pci_driver);
 }
-- 
2.33.1



[PATCH 31/60] drm/r128: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/r128/r128_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/r128/r128_drv.c b/drivers/gpu/drm/r128/r128_drv.c
index e35a3a1449bd..e49db9692df9 100644
--- a/drivers/gpu/drm/r128/r128_drv.c
+++ b/drivers/gpu/drm/r128/r128_drv.c
@@ -98,6 +98,9 @@ static struct pci_driver r128_pci_driver = {
 
 static int __init r128_init(void)
 {
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
driver.num_ioctls = r128_max_ioctl;
 
return drm_legacy_pci_init(, _pci_driver);
-- 
2.33.1



[PATCH 42/60] drm/tegra: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/tegra/drm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index 8d37d6b00562..48e35d686473 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -1382,6 +1382,9 @@ static int __init host1x_drm_init(void)
 {
int err;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
err = host1x_driver_register(_drm_driver);
if (err < 0)
return err;
-- 
2.33.1



[PATCH 35/60] drm/shmobile: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/shmobile/shmob_drm_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/shmobile/shmob_drm_drv.c 
b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
index 80078a9fd7f6..7011c659a921 100644
--- a/drivers/gpu/drm/shmobile/shmob_drm_drv.c
+++ b/drivers/gpu/drm/shmobile/shmob_drm_drv.c
@@ -195,6 +195,9 @@ static int shmob_drm_probe(struct platform_device *pdev)
unsigned int i;
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
if (pdata == NULL) {
dev_err(>dev, "no platform data\n");
return -EINVAL;
-- 
2.33.1



[PATCH 37/60] drm/sprd: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/sprd/sprd_drm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/sprd/sprd_drm.c b/drivers/gpu/drm/sprd/sprd_drm.c
index a077e2d4d721..dd7e3de780f3 100644
--- a/drivers/gpu/drm/sprd/sprd_drm.c
+++ b/drivers/gpu/drm/sprd/sprd_drm.c
@@ -186,6 +186,9 @@ static struct platform_driver *sprd_drm_drivers[]  = {
 
 static int __init sprd_drm_init(void)
 {
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
return platform_register_drivers(sprd_drm_drivers,
ARRAY_SIZE(sprd_drm_drivers));
 }
-- 
2.33.1



[PATCH 48/60] drm/ili9163: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/tiny/ili9163.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/tiny/ili9163.c b/drivers/gpu/drm/tiny/ili9163.c
index bcc181351236..60afabc6bb35 100644
--- a/drivers/gpu/drm/tiny/ili9163.c
+++ b/drivers/gpu/drm/tiny/ili9163.c
@@ -146,6 +146,9 @@ static int ili9163_probe(struct spi_device *spi)
u32 rotation = 0;
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
dbidev = devm_drm_dev_alloc(dev, _driver,
struct mipi_dbi_dev, drm);
if (IS_ERR(dbidev))
-- 
2.33.1



[PATCH 38/60] drm/sti: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/sti/sti_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
index c7efb43b83ee..860b2230aa08 100644
--- a/drivers/gpu/drm/sti/sti_drv.c
+++ b/drivers/gpu/drm/sti/sti_drv.c
@@ -287,6 +287,9 @@ static struct platform_driver * const drivers[] = {
 
 static int sti_drm_init(void)
 {
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
return platform_register_drivers(drivers, ARRAY_SIZE(drivers));
 }
 module_init(sti_drm_init);
-- 
2.33.1



[PATCH 10/60] drm/gma500: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/gma500/psb_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index 65cf1c79dd7c..eeb681be9c95 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -538,6 +538,9 @@ static struct pci_driver psb_pci_driver = {
 
 static int __init psb_init(void)
 {
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
return pci_register_driver(_pci_driver);
 }
 
-- 
2.33.1



[PATCH 23/60] drm/meson: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/meson/meson_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/meson/meson_drv.c 
b/drivers/gpu/drm/meson/meson_drv.c
index 80f1d439841a..719724ad3c5b 100644
--- a/drivers/gpu/drm/meson/meson_drv.c
+++ b/drivers/gpu/drm/meson/meson_drv.c
@@ -456,6 +456,9 @@ static int meson_drv_probe(struct platform_device *pdev)
struct device_node *ep, *remote;
int count = 0;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
for_each_endpoint_of_node(np, ep) {
remote = of_graph_get_remote_port_parent(ep);
if (!remote || !of_device_is_available(remote)) {
-- 
2.33.1



[PATCH 21/60] drm/mcde: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/mcde/mcde_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/mcde/mcde_drv.c b/drivers/gpu/drm/mcde/mcde_drv.c
index 5b5afc6aaf8e..0b2910e69b42 100644
--- a/drivers/gpu/drm/mcde/mcde_drv.c
+++ b/drivers/gpu/drm/mcde/mcde_drv.c
@@ -491,6 +491,9 @@ static int __init mcde_drm_register(void)
 {
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
ret = platform_register_drivers(component_drivers,
ARRAY_SIZE(component_drivers));
if (ret)
-- 
2.33.1



[PATCH 15/60] drm/i810: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/i810/i810_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/i810/i810_drv.c b/drivers/gpu/drm/i810/i810_drv.c
index 0e53a066d4db..7ce268b54a18 100644
--- a/drivers/gpu/drm/i810/i810_drv.c
+++ b/drivers/gpu/drm/i810/i810_drv.c
@@ -80,6 +80,9 @@ static struct pci_driver i810_pci_driver = {
 
 static int __init i810_init(void)
 {
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
if (num_possible_cpus() > 1) {
pr_err("drm/i810 does not support SMP\n");
return -EINVAL;
-- 
2.33.1



[PATCH 16/60] drm/imx/dcss: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/imx/dcss/dcss-drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/imx/dcss/dcss-drv.c 
b/drivers/gpu/drm/imx/dcss/dcss-drv.c
index 8dc2f85c514b..5be591da7389 100644
--- a/drivers/gpu/drm/imx/dcss/dcss-drv.c
+++ b/drivers/gpu/drm/imx/dcss/dcss-drv.c
@@ -38,6 +38,9 @@ static int dcss_drv_platform_probe(struct platform_device 
*pdev)
int err = 0;
bool hdmi_output = true;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
if (!dev->of_node)
return -ENODEV;
 
-- 
2.33.1



[PATCH 20/60] drm/lima: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/lima/lima_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/lima/lima_drv.c b/drivers/gpu/drm/lima/lima_drv.c
index 7b8d7178d09a..9255073162db 100644
--- a/drivers/gpu/drm/lima/lima_drv.c
+++ b/drivers/gpu/drm/lima/lima_drv.c
@@ -375,6 +375,9 @@ static int lima_pdev_probe(struct platform_device *pdev)
struct drm_device *ddev;
int err;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
err = lima_sched_slab_init();
if (err)
return err;
-- 
2.33.1



[PATCH 14/60] drm/hyperv: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/hyperv/hyperv_drm_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/hyperv/hyperv_drm_drv.c 
b/drivers/gpu/drm/hyperv/hyperv_drm_drv.c
index cd818a629183..8401a43c4d49 100644
--- a/drivers/gpu/drm/hyperv/hyperv_drm_drv.c
+++ b/drivers/gpu/drm/hyperv/hyperv_drm_drv.c
@@ -288,6 +288,9 @@ static int __init hyperv_init(void)
 {
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
ret = pci_register_driver(_pci_driver);
if (ret != 0)
return ret;
-- 
2.33.1



[PATCH 17/60] drm/imx: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/imx/imx-drm-core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/imx/imx-drm-core.c 
b/drivers/gpu/drm/imx/imx-drm-core.c
index cb685fe2039b..a57812ec36b1 100644
--- a/drivers/gpu/drm/imx/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/imx-drm-core.c
@@ -341,6 +341,9 @@ static struct platform_driver * const drivers[] = {
 
 static int __init imx_drm_init(void)
 {
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
return platform_register_drivers(drivers, ARRAY_SIZE(drivers));
 }
 module_init(imx_drm_init);
-- 
2.33.1



[PATCH 12/60] drm/hisilicon/hibmc: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
Patch-cc:Tian Tao 
---

 drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c 
b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
index 610fc8e135f9..f66de93831c6 100644
--- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c
@@ -315,6 +315,9 @@ static int hibmc_pci_probe(struct pci_dev *pdev,
struct drm_device *dev;
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, 
_driver);
if (ret)
return ret;
-- 
2.33.1



[PATCH 22/60] drm/mediatek: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/mediatek/mtk_drm_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c 
b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
index aec39724ebeb..e336358fee20 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -210,6 +210,9 @@ static int mtk_drm_kms_init(struct drm_device *drm)
struct device *dma_dev;
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
if (!iommu_present(_bus_type))
return -EPROBE_DEFER;
 
-- 
2.33.1



[PATCH 11/60] drm/gud: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/gud/gud_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/gud/gud_drv.c b/drivers/gpu/drm/gud/gud_drv.c
index 3f9d4b9a1e3d..4d253d249512 100644
--- a/drivers/gpu/drm/gud/gud_drv.c
+++ b/drivers/gpu/drm/gud/gud_drv.c
@@ -446,6 +446,9 @@ static int gud_probe(struct usb_interface *intf, const 
struct usb_device_id *id)
u32 *formats;
int ret, i;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
ret = usb_find_bulk_out_endpoint(intf->cur_altsetting, _out);
if (ret)
return ret;
-- 
2.33.1



[PATCH 07/60] drm/etnaviv: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/etnaviv/etnaviv_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c 
b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
index 7dcc6392792d..58b092248f7b 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
@@ -635,6 +635,9 @@ static int __init etnaviv_init(void)
int ret;
struct device_node *np;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
etnaviv_validate_init();
 
ret = platform_driver_register(_gpu_driver);
-- 
2.33.1



[PATCH 13/60] drm/hisilicon/kirin: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c 
b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
index 98ae9a48f3fe..2f4c81dc8681 100644
--- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
+++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
@@ -274,6 +274,9 @@ static int kirin_drm_platform_probe(struct platform_device 
*pdev)
struct component_match *match = NULL;
struct device_node *remote;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
remote = of_graph_get_remote_node(np, 0, 0);
if (!remote)
return -ENODEV;
-- 
2.33.1



[PATCH 09/60] drm/fsl-dcu: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c 
b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
index 660fe573db96..9b9e1b25 100644
--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
+++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c
@@ -255,6 +255,9 @@ static int fsl_dcu_drm_probe(struct platform_device *pdev)
int ret;
u8 div_ratio_shift = 0;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
fsl_dev = devm_kzalloc(dev, sizeof(*fsl_dev), GFP_KERNEL);
if (!fsl_dev)
return -ENOMEM;
-- 
2.33.1



[PATCH 00/60] drm: Make all drivers to honour the nomodeset parameter

2021-12-14 Thread Javier Martinez Canillas
The nomodeset kernel command line parameter is used to prevent the KMS/DRM
drivers to be registered/probed. But only a few drivers implement support
for this parameter and most DRM drivers would just ignore it.

This (huge) patch series makes all DRM drivers to honour this parameter. It
is posted as separate patches to make easier for drivers maintainers to ack
or pick them independently at their own pace.

Patches are quite trivial and just add an if (drm_firmware_drivers_only())
check and return -ENODEV if that's true. The condition is checked as early
as possible, that is in the module_init handler for drivers that have one
or in the probe function for drivers that are using the module_*_driver()
macros and don't have their own module init function.

I included all the DRM drivers that think makes sense. I only left the vc4
and v3d drivers, that Maxime is already handling in another patch series
and the vgem, vkms and simpledrm drivers that should ignore the param IMO.

I've built tested with 'make allmodconfig && make M=drivers/gpu/drm/', but
only booted in a few devices with and without nomodeset in the cmdline. So
testing and reviewing for all the drivers would be highly appreciated.

Best regards,
Javier


Javier Martinez Canillas (60):
  drm/komeda: Add support for the nomodeset kernel parameter
  drm/arm/hdlcd: Add support for the nomodeset kernel parameter
  drm/malidp: Add support for the nomodeset kernel parameter
  drm/armada: Add support for the nomodeset kernel parameter
  drm/aspeed: Add support for the nomodeset kernel parameter
  drm/atmel-hlcdc: Add support for the nomodeset kernel parameter
  drm/etnaviv: Add support for the nomodeset kernel parameter
  drm/exynos: Add support for the nomodeset kernel parameter
  drm/fsl-dcu: Add support for the nomodeset kernel parameter
  drm/gma500: Add support for the nomodeset kernel parameter
  drm/gud: Add support for the nomodeset kernel parameter
  drm/hisilicon/hibmc: Add support for the nomodeset kernel parameter
  drm/hisilicon/kirin: Add support for the nomodeset kernel parameter
  drm/hyperv: Add support for the nomodeset kernel parameter
  drm/i810: Add support for the nomodeset kernel parameter
  drm/imx/dcss: Add support for the nomodeset kernel parameter
  drm/imx: Add support for the nomodeset kernel parameter
  drm/ingenic: Add support for the nomodeset kernel parameter
  drm/kmb: Add support for the nomodeset kernel parameter
  drm/lima: Add support for the nomodeset kernel parameter
  drm/mcde: Add support for the nomodeset kernel parameter
  drm/mediatek: Add support for the nomodeset kernel parameter
  drm/meson: Add support for the nomodeset kernel parameter
  drm/mga: Add support for the nomodeset kernel parameter
  drm/msm: Add support for the nomodeset kernel parameter
  drm: mxsfb: Add support for the nomodeset kernel parameter
  drm/omap: Add support for the nomodeset kernel parameter
  drm/panel: ilitek-ili9341: Add support for the nomodeset kernel
parameter
  drm/panfrost: Add support for the nomodeset kernel parameter
  drm/pl111: Add support for the nomodeset kernel parameter
  drm/r128: Add support for the nomodeset kernel parameter
  drm: rcar-du: Add support for the nomodeset kernel parameter
  drm/rockchip: Add support for the nomodeset kernel parameter
  drm/savage: Add support for the nomodeset kernel parameter
  drm/shmobile: Add support for the nomodeset kernel parameter
  drm/sis: Add support for the nomodeset kernel parameter
  drm/sprd: Add support for the nomodeset kernel parameter
  drm/sti: Add support for the nomodeset kernel parameter
  drm/stm: Add support for the nomodeset kernel parameter
  drm/sun4i: Add support for the nomodeset kernel parameter
  drm/tdfx: Add support for the nomodeset kernel parameter
  drm/tegra: Add support for the nomodeset kernel parameter
  drm/tidss: Add support for the nomodeset kernel parameter
  drm/tilcdc: Add support for the nomodeset kernel parameter
  drm/arc: Add support for the nomodeset kernel parameter
  drm/gm12u320: Add support for the nomodeset kernel parameter
  drm/hx8357d: Add support for the nomodeset kernel parameter
  drm/ili9163: Add support for the nomodeset kernel parameter
  drm/ili9225: Add support for the nomodeset kernel parameter
  drm/ili9341: Add support for the nomodeset kernel parameter
  drm/ili9486: Add support for the nomodeset kernel parameter
  drm/mi0283qt: Add support for the nomodeset kernel parameter
  drm/repaper: Add support for the nomodeset kernel parameter
  drm/st7586: Add support for the nomodeset kernel parameter
  drm/st7735r: Add support for the nomodeset kernel parameter
  drm/tve200: Add support for the nomodeset kernel parameter
  drm/udl: Add support for the nomodeset kernel parameter
  drm/via: Add support for the nomodeset kernel parameter
  drm/xen: Add support for the nomodeset kernel parameter
  drm/xlnx: Add support for the nomodeset kernel parameter

 drivers/gpu/drm/arm/display/komeda/komeda_drv.c | 4 
 

[PATCH 04/60] drm/armada: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/armada/armada_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/armada/armada_drv.c 
b/drivers/gpu/drm/armada/armada_drv.c
index 8e3e98f13db4..4f9b0a9f13e3 100644
--- a/drivers/gpu/drm/armada/armada_drv.c
+++ b/drivers/gpu/drm/armada/armada_drv.c
@@ -273,6 +273,9 @@ static int __init armada_drm_init(void)
 {
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
ret = platform_driver_register(_lcd_platform_driver);
if (ret)
return ret;
-- 
2.33.1



[PATCH 05/60] drm/aspeed: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c 
b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
index b53fee6f1c17..c70d8f046816 100644
--- a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
+++ b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
@@ -310,6 +310,9 @@ static int aspeed_gfx_probe(struct platform_device *pdev)
struct aspeed_gfx *priv;
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
priv = devm_drm_dev_alloc(>dev, _gfx_driver,
  struct aspeed_gfx, drm);
if (IS_ERR(priv))
-- 
2.33.1



[PATCH 08/60] drm/exynos: Add support for the nomodeset kernel parameter

2021-12-14 Thread Javier Martinez Canillas
According to disable Documentation/admin-guide/kernel-parameters.txt, this
parameter can be used to disable kernel modesetting.

DRM drivers will not perform display-mode changes or accelerated rendering
and only the systewm system framebuffer will be available if it was set-up.

But only a few DRM drivers currently check for nomodeset, make this driver
to also support the command line parameter.

Signed-off-by: Javier Martinez Canillas 
---

 drivers/gpu/drm/exynos/exynos_drm_drv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c 
b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index d8f1cf4d6b69..f9f10413a4f2 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -464,6 +464,9 @@ static int exynos_drm_init(void)
 {
int ret;
 
+   if (drm_firmware_drivers_only())
+   return -ENODEV;
+
ret = exynos_drm_register_devices();
if (ret)
return ret;
-- 
2.33.1



  1   2   3   >