From f8c0659ce8481143371e8a26a754e52a219f749d Mon Sep 17 00:00:00 2001 From: zouxiaoh Date: Mon, 22 May 2023 18:16:57 +0800 Subject: [PATCH] Realsense PV release for ADL-P. (#143) Signed-off-by: zouxiaoh --- drivers/media/i2c/d4xx.c | 2 +- drivers/media/pci/intel/ipu-buttress.h | 2 +- .../media/pci/intel/ipu-isys-csi2-be-soc.c | 1 + drivers/media/pci/intel/ipu-isys-video.c | 35 +++++++++++++++++++ drivers/media/pci/intel/ipu.c | 32 +++++++++++++---- 5 files changed, 64 insertions(+), 8 deletions(-) diff --git a/drivers/media/i2c/d4xx.c b/drivers/media/i2c/d4xx.c index 2f2aa530b388..b70977afd2b3 100644 --- a/drivers/media/i2c/d4xx.c +++ b/drivers/media/i2c/d4xx.c @@ -987,7 +987,7 @@ static const struct ds5_format ds5_y_formats_ds5u[] = { { /* First format: default */ .data_type = 0x2a, /* Y8 */ - .mbus_code = MEDIA_BUS_FMT_SBGGR8_1X8, + .mbus_code = MEDIA_BUS_FMT_Y8_1X8, .n_resolutions = ARRAY_SIZE(y8_sizes), .resolutions = y8_sizes, }, { diff --git a/drivers/media/pci/intel/ipu-buttress.h b/drivers/media/pci/intel/ipu-buttress.h index cfe008f749f4..81ee5ab8a40f 100644 --- a/drivers/media/pci/intel/ipu-buttress.h +++ b/drivers/media/pci/intel/ipu-buttress.h @@ -20,7 +20,7 @@ #define BUTTRESS_IS_FREQ_STEP 25U #define BUTTRESS_MIN_FORCE_IS_FREQ (BUTTRESS_IS_FREQ_STEP * 8) -#define BUTTRESS_MAX_FORCE_IS_FREQ (BUTTRESS_IS_FREQ_STEP * 16) +#define BUTTRESS_MAX_FORCE_IS_FREQ (BUTTRESS_IS_FREQ_STEP * 22) struct ipu_buttress_ctrl { u32 freq_ctl, pwr_sts_shift, pwr_sts_mask, pwr_sts_on, pwr_sts_off; diff --git a/drivers/media/pci/intel/ipu-isys-csi2-be-soc.c b/drivers/media/pci/intel/ipu-isys-csi2-be-soc.c index 5c5275cb8aa4..caf3654d4e8d 100644 --- a/drivers/media/pci/intel/ipu-isys-csi2-be-soc.c +++ b/drivers/media/pci/intel/ipu-isys-csi2-be-soc.c @@ -39,6 +39,7 @@ static const u32 csi2_be_soc_supported_codes_pad[] = { MEDIA_BUS_FMT_SGRBG8_1X8, MEDIA_BUS_FMT_SRGGB8_1X8, MEDIA_BUS_FMT_Y8_1X8, + MEDIA_BUS_FMT_FIXED, 0, }; diff --git a/drivers/media/pci/intel/ipu-isys-video.c b/drivers/media/pci/intel/ipu-isys-video.c index fe2e44349714..553fa7513b8b 100644 --- a/drivers/media/pci/intel/ipu-isys-video.c +++ b/drivers/media/pci/intel/ipu-isys-video.c @@ -82,6 +82,7 @@ const struct ipu_isys_pixelformat ipu_isys_pfmts_be_soc[] = { IPU_FW_ISYS_FRAME_FORMAT_RAW8}, {V4L2_PIX_FMT_GREY, 8, 8, 0, MEDIA_BUS_FMT_Y8_1X8, IPU_FW_ISYS_FRAME_FORMAT_RAW8}, + {V4L2_META_FMT_D4XX, 8, 8, 0, MEDIA_BUS_FMT_FIXED, 0}, {} }; @@ -417,6 +418,16 @@ static int vidioc_g_fmt_vid_cap_mplane(struct file *file, void *fh, { struct ipu_isys_video *av = video_drvdata(file); + if (fmt->type == V4L2_BUF_TYPE_META_CAPTURE) { + fmt->fmt.meta.buffersize = av->mpix.plane_fmt[0].sizeimage; + fmt->fmt.meta.bytesperline = av->mpix.plane_fmt[0].bytesperline; + fmt->fmt.meta.width = av->mpix.width; + fmt->fmt.meta.height = av->mpix.height; + fmt->fmt.meta.dataformat = av->mpix.pixelformat; + + return 0; + } + fmt->fmt.pix_mp = av->mpix; return 0; @@ -540,10 +551,29 @@ static int vidioc_s_fmt_vid_cap_mplane(struct file *file, void *fh, struct v4l2_format *f) { struct ipu_isys_video *av = video_drvdata(file); + struct v4l2_pix_format_mplane mpix; if (av->aq.vbq.streaming) return -EBUSY; + if (f->type == V4L2_BUF_TYPE_META_CAPTURE) { + memset(&av->mpix, 0, sizeof(av->mpix)); + memset(&mpix, 0, sizeof(mpix)); + mpix.width = f->fmt.meta.width; + mpix.height = f->fmt.meta.height; + mpix.pixelformat = f->fmt.meta.dataformat; + av->pfmt = av->try_fmt_vid_mplane(av, &mpix); + av->aq.vbq.type = V4L2_BUF_TYPE_META_CAPTURE; + av->aq.vbq.is_multiplanar = false; + av->aq.vbq.is_output = false; + av->mpix = mpix; + f->fmt.meta.width = mpix.width; + f->fmt.meta.height = mpix.height; + f->fmt.meta.dataformat = mpix.pixelformat; + f->fmt.meta.bytesperline = mpix.plane_fmt[0].bytesperline; + f->fmt.meta.buffersize = mpix.plane_fmt[0].sizeimage; + return 0; + } av->pfmt = av->try_fmt_vid_mplane(av, &f->fmt.pix_mp); av->mpix = f->fmt.pix_mp; @@ -2333,6 +2363,10 @@ static const struct v4l2_ioctl_ops ioctl_ops_mplane = { .vidioc_g_fmt_vid_cap_mplane = vidioc_g_fmt_vid_cap_mplane, .vidioc_s_fmt_vid_cap_mplane = vidioc_s_fmt_vid_cap_mplane, .vidioc_try_fmt_vid_cap_mplane = vidioc_try_fmt_vid_cap_mplane, + .vidioc_enum_fmt_meta_cap = ipu_isys_vidioc_enum_fmt, + .vidioc_g_fmt_meta_cap = vidioc_g_fmt_vid_cap_mplane, + .vidioc_s_fmt_meta_cap = vidioc_s_fmt_vid_cap_mplane, + .vidioc_try_fmt_meta_cap = vidioc_try_fmt_vid_cap_mplane, .vidioc_reqbufs = vb2_ioctl_reqbufs, .vidioc_create_bufs = vb2_ioctl_create_bufs, .vidioc_prepare_buf = vb2_ioctl_prepare_buf, @@ -2401,6 +2435,7 @@ int ipu_isys_video_init(struct ipu_isys_video *av, av->aq.vbq.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; ioctl_ops = &ioctl_ops_mplane; av->vdev.device_caps |= V4L2_CAP_VIDEO_CAPTURE_MPLANE; + av->vdev.device_caps |= V4L2_CAP_META_CAPTURE; av->vdev.vfl_dir = VFL_DIR_RX; } else { av->aq.vbq.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; diff --git a/drivers/media/pci/intel/ipu.c b/drivers/media/pci/intel/ipu.c index 8a812a90c940..7d3ad387f391 100644 --- a/drivers/media/pci/intel/ipu.c +++ b/drivers/media/pci/intel/ipu.c @@ -41,9 +41,13 @@ enum ipu_version ipu_ver; EXPORT_SYMBOL(ipu_ver); -static int isys_freq_overwrite = -1; -module_param(isys_freq_overwrite, int, 0660); -MODULE_PARM_DESC(isys_freq_overwrite, "overwrite isys freq default value"); +static int isys_freq_override = -1; +module_param(isys_freq_override, int, 0660); +MODULE_PARM_DESC(isys_freq_override, "override isys freq default value"); + +static int psys_freq_override = -1; +module_param(psys_freq_override, int, 0660); +MODULE_PARM_DESC(psys_freq_override, "override psys freq default value"); #if IS_ENABLED(CONFIG_INTEL_IPU6_ACPI) static int isys_init_acpi_add_device(struct device *dev, void *priv, @@ -656,12 +660,16 @@ static int ipu_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto out_ipu_bus_del_devices; } - if ((isys_freq_overwrite >= IPU_IS_FREQ_MIN) && (isys_freq_overwrite <= IPU_IS_FREQ_MAX)) { - u64 val = isys_freq_overwrite; + if (isys_freq_override >= BUTTRESS_MIN_FORCE_IS_FREQ && + isys_freq_override <= BUTTRESS_MAX_FORCE_IS_FREQ) { + u64 val = isys_freq_override; do_div(val, BUTTRESS_IS_FREQ_STEP); - dev_info(&isp->pdev->dev, "isys freq overwrite to %d\n", isys_freq_overwrite); isys_ctrl->divisor = val; + dev_info(&isp->pdev->dev, + "adusted isys freq from input (%d) and set (%d)\n", + isys_freq_override, + isys_ctrl->divisor * BUTTRESS_IS_FREQ_STEP); } psys_ctrl = devm_kzalloc(&pdev->dev, sizeof(*psys_ctrl), GFP_KERNEL); @@ -681,6 +689,18 @@ static int ipu_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto out_ipu_bus_del_devices; } + if (psys_freq_override >= BUTTRESS_MIN_FORCE_PS_FREQ && + psys_freq_override <= BUTTRESS_MAX_FORCE_PS_FREQ) { + u64 val = psys_freq_override; + + do_div(val, BUTTRESS_PS_FREQ_STEP); + psys_ctrl->divisor = val; + psys_ctrl->qos_floor = val; + dev_info(&isp->pdev->dev, + "adjusted psys freq from input (%d) and set (%d)\n", + psys_freq_override, + psys_ctrl->divisor * BUTTRESS_PS_FREQ_STEP); + } rval = pm_runtime_get_sync(&isp->psys->dev); if (rval < 0) { dev_err(&isp->psys->dev, "Failed to get runtime PM\n");