From b1f3677aebe5a9352a02b40465e71313f91cbd12 Mon Sep 17 00:00:00 2001 From: Uwe Kleine-König Date: Fri, 8 Mar 2024 09:51:16 +0100 Subject: media: staging: media: starfive: camss: Convert to platform remove callback returning void MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new(), which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove(). Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-König Reviewed-by: Changhuang Liang Signed-off-by: Hans Verkuil --- drivers/staging/media/starfive/camss/stf-camss.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/starfive/camss/stf-camss.c b/drivers/staging/media/starfive/camss/stf-camss.c index a587f860101a..f9613c2c9dfe 100644 --- a/drivers/staging/media/starfive/camss/stf-camss.c +++ b/drivers/staging/media/starfive/camss/stf-camss.c @@ -355,7 +355,7 @@ err_cleanup_notifier: * * Always returns 0. */ -static int stfcamss_remove(struct platform_device *pdev) +static void stfcamss_remove(struct platform_device *pdev) { struct stfcamss *stfcamss = platform_get_drvdata(pdev); @@ -364,8 +364,6 @@ static int stfcamss_remove(struct platform_device *pdev) media_device_cleanup(&stfcamss->media_dev); v4l2_async_nf_cleanup(&stfcamss->notifier); pm_runtime_disable(&pdev->dev); - - return 0; } static const struct of_device_id stfcamss_of_match[] = { @@ -420,7 +418,7 @@ static const struct dev_pm_ops stfcamss_pm_ops = { static struct platform_driver stfcamss_driver = { .probe = stfcamss_probe, - .remove = stfcamss_remove, + .remove_new = stfcamss_remove, .driver = { .name = "starfive-camss", .pm = &stfcamss_pm_ops, -- cgit v1.2.3 From 810dd605e917c716f6f83e6cd8ea23d9155d32a2 Mon Sep 17 00:00:00 2001 From: Changhuang Liang Date: Mon, 11 Mar 2024 05:03:09 -0700 Subject: staging: media: starfive: Remove links when unregistering devices Need to remove links when unregistering devices. Fixes: ac7da4a73b10 ("media: staging: media: starfive: camss: Register devices") Signed-off-by: Changhuang Liang Signed-off-by: Hans Verkuil --- drivers/staging/media/starfive/camss/stf-camss.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'drivers/staging') diff --git a/drivers/staging/media/starfive/camss/stf-camss.c b/drivers/staging/media/starfive/camss/stf-camss.c index f9613c2c9dfe..fecd3e67c7a1 100644 --- a/drivers/staging/media/starfive/camss/stf-camss.c +++ b/drivers/staging/media/starfive/camss/stf-camss.c @@ -162,6 +162,12 @@ err_isp_unregister: static void stfcamss_unregister_devs(struct stfcamss *stfcamss) { + struct stf_capture *cap_yuv = &stfcamss->captures[STF_CAPTURE_YUV]; + struct stf_isp_dev *isp_dev = &stfcamss->isp_dev; + + media_entity_remove_links(&isp_dev->subdev.entity); + media_entity_remove_links(&cap_yuv->video.vdev.entity); + stf_isp_unregister(&stfcamss->isp_dev); stf_capture_unregister(stfcamss); } -- cgit v1.2.3 From dd44a571789fb3128dbe4daa6030e44d9e304911 Mon Sep 17 00:00:00 2001 From: Ricardo Ribalda Date: Mon, 25 Mar 2024 14:50:23 +0000 Subject: staging: media: tegra-video: Fix -Wmaybe-unitialized warn in gcc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make sure that tegra20_vi_get_input_formats always assign a value for yuv_input_format. Fix: drivers/staging/media/tegra-video/tegra20.c:624:72: warning: ‘yuv_input_format’ may be used uninitialized [-Wmaybe-uninitialized] Signed-off-by: Ricardo Ribalda Reviewed-by: Luca Ceresoli Signed-off-by: Hans Verkuil --- drivers/staging/media/tegra-video/tegra20.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/staging') diff --git a/drivers/staging/media/tegra-video/tegra20.c b/drivers/staging/media/tegra-video/tegra20.c index c25286772603..630e2ff987a3 100644 --- a/drivers/staging/media/tegra-video/tegra20.c +++ b/drivers/staging/media/tegra-video/tegra20.c @@ -164,6 +164,7 @@ static void tegra20_vi_get_input_formats(struct tegra_vi_channel *chan, unsigned int input_mbus_code = chan->fmtinfo->code; (*main_input_format) = VI_INPUT_INPUT_FORMAT_YUV422; + (*yuv_input_format) = VI_INPUT_YUV_INPUT_FORMAT_UYVY; switch (input_mbus_code) { case MEDIA_BUS_FMT_UYVY8_2X8: -- cgit v1.2.3 From e98bf52803b35954e2a40c0f8ebc4579334d7cc2 Mon Sep 17 00:00:00 2001 From: Paweł Anikiel Date: Fri, 5 Apr 2024 14:14:10 +0000 Subject: media: tegra-video: Use pad variant of dv timing subdev calls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the pad variant for all (s|g|query)_dv_timings subdev calls, which includes a pad argument. Signed-off-by: Paweł Anikiel Signed-off-by: Hans Verkuil --- drivers/staging/media/tegra-video/vi.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index af6e3a0d8df4..57a856a21e90 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -719,11 +719,11 @@ static int tegra_channel_g_dv_timings(struct file *file, void *fh, struct v4l2_subdev *subdev; subdev = tegra_channel_get_remote_source_subdev(chan); - if (!v4l2_subdev_has_op(subdev, video, g_dv_timings)) + if (!v4l2_subdev_has_op(subdev, pad, g_dv_timings)) return -ENOTTY; return v4l2_device_call_until_err(chan->video.v4l2_dev, 0, - video, g_dv_timings, timings); + pad, g_dv_timings, 0, timings); } static int tegra_channel_s_dv_timings(struct file *file, void *fh, @@ -736,7 +736,7 @@ static int tegra_channel_s_dv_timings(struct file *file, void *fh, int ret; subdev = tegra_channel_get_remote_source_subdev(chan); - if (!v4l2_subdev_has_op(subdev, video, s_dv_timings)) + if (!v4l2_subdev_has_op(subdev, pad, s_dv_timings)) return -ENOTTY; ret = tegra_channel_g_dv_timings(file, fh, &curr_timings); @@ -750,7 +750,7 @@ static int tegra_channel_s_dv_timings(struct file *file, void *fh, return -EBUSY; ret = v4l2_device_call_until_err(chan->video.v4l2_dev, 0, - video, s_dv_timings, timings); + pad, s_dv_timings, 0, timings); if (ret) return ret; @@ -771,11 +771,11 @@ static int tegra_channel_query_dv_timings(struct file *file, void *fh, struct v4l2_subdev *subdev; subdev = tegra_channel_get_remote_source_subdev(chan); - if (!v4l2_subdev_has_op(subdev, video, query_dv_timings)) + if (!v4l2_subdev_has_op(subdev, pad, query_dv_timings)) return -ENOTTY; return v4l2_device_call_until_err(chan->video.v4l2_dev, 0, - video, query_dv_timings, timings); + pad, query_dv_timings, 0, timings); } static int tegra_channel_enum_dv_timings(struct file *file, void *fh, -- cgit v1.2.3 From 2f57779ce413a9235509b4f9ed0765d12625ac30 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Thu, 28 Mar 2024 11:44:55 +0000 Subject: staging: media: ipu3: remove redundant assignment to pointer css_pipe Pointer css_pipe is being assigned a value that is never read afterwards. The assignment is redundant and can be removed. Cleans up clang scan build warning: drivers/staging/media/ipu3/ipu3-css.c:2058:3: warning: Value stored to 'css_pipe' is never read [deadcode.DeadStores] Signed-off-by: Colin Ian King Signed-off-by: Sakari Ailus Signed-off-by: Hans Verkuil --- drivers/staging/media/ipu3/ipu3-css.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/ipu3/ipu3-css.c b/drivers/staging/media/ipu3/ipu3-css.c index 9c10f1474c35..1b0a59b78949 100644 --- a/drivers/staging/media/ipu3/ipu3-css.c +++ b/drivers/staging/media/ipu3/ipu3-css.c @@ -2055,7 +2055,6 @@ struct imgu_css_buffer *imgu_css_buf_dequeue(struct imgu_css *css) return ERR_PTR(-EIO); } - css_pipe = &css->pipes[pipe]; dev_dbg(css->dev, "event: pipeline done 0x%8x for pipe %d\n", event, pipe); break; -- cgit v1.2.3 From f55aa90b88994f58796022af71001cda2a4ddf83 Mon Sep 17 00:00:00 2001 From: Rajeshwar R Shinde Date: Fri, 29 Mar 2024 11:14:46 +0530 Subject: staging: media: imx: Remove duplicate Kconfig dependency The kernel configuration VIDEO_DEV is defined twice in Kconfig. Thus, the duplicate Kconfig dependency is removed. Signed-off-by: Rajeshwar R Shinde Signed-off-by: Sakari Ailus Signed-off-by: Hans Verkuil --- drivers/staging/media/imx/Kconfig | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/imx/Kconfig b/drivers/staging/media/imx/Kconfig index 426310e1ea5b..1cd48028b641 100644 --- a/drivers/staging/media/imx/Kconfig +++ b/drivers/staging/media/imx/Kconfig @@ -4,7 +4,6 @@ config VIDEO_IMX_MEDIA depends on ARCH_MXC || COMPILE_TEST depends on HAS_DMA depends on VIDEO_DEV - depends on VIDEO_DEV depends on IMX_IPUV3_CORE select MEDIA_CONTROLLER select V4L2_FWNODE -- cgit v1.2.3 From 34793224b6dfd59cb17e8f77b81711f437c32f48 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Thu, 4 Apr 2024 11:41:15 +0300 Subject: staging: media: ipu3-imgu: Update e-mail addresses Remove e-mail addresses no longer in use. Signed-off-by: Sakari Ailus Signed-off-by: Hans Verkuil --- drivers/staging/media/ipu3/ipu3.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/ipu3/ipu3.c b/drivers/staging/media/ipu3/ipu3.c index 18ca22c3018a..215884b3e922 100644 --- a/drivers/staging/media/ipu3/ipu3.c +++ b/drivers/staging/media/ipu3/ipu3.c @@ -853,10 +853,10 @@ static struct pci_driver imgu_pci_driver = { module_pci_driver(imgu_pci_driver); -MODULE_AUTHOR("Tuukka Toivonen "); +MODULE_AUTHOR("Tuukka Toivonen"); MODULE_AUTHOR("Tianshu Qiu "); -MODULE_AUTHOR("Jian Xu Zheng "); -MODULE_AUTHOR("Yuning Pu "); +MODULE_AUTHOR("Jian Xu Zheng"); +MODULE_AUTHOR("Yuning Pu"); MODULE_AUTHOR("Yong Zhi "); MODULE_LICENSE("GPL v2"); MODULE_DESCRIPTION("Intel ipu3_imgu PCI driver"); -- cgit v1.2.3 From 1e1e504eeaea184ab1ca731131cbd8d614d08479 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 19 Feb 2024 14:19:56 +0100 Subject: media: atomisp: Fix double negation in unsupported revision error s/is not unsupported/is not supported/ in the unsupported revision error. Suggested-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_v4l2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c index f736e54c7df3..5a97013094f2 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c +++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c @@ -1363,7 +1363,7 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i } if (pdev->revision <= ATOMISP_PCI_REV_BYT_A0_MAX) { - dev_err(&pdev->dev, "revision %d is not unsupported\n", pdev->revision); + dev_err(&pdev->dev, "revision %d is not supported\n", pdev->revision); return -ENODEV; } -- cgit v1.2.3 From 3b621e9e9e148c0928ab109ac3d4b81487469acb Mon Sep 17 00:00:00 2001 From: Zhipeng Lu Date: Thu, 18 Jan 2024 16:13:00 +0100 Subject: media: atomisp: ssh_css: Fix a null-pointer dereference in load_video_binaries The allocation failure of mycs->yuv_scaler_binary in load_video_binaries() is followed with a dereference of mycs->yuv_scaler_binary after the following call chain: sh_css_pipe_load_binaries() |-> load_video_binaries(mycs->yuv_scaler_binary == NULL) | |-> sh_css_pipe_unload_binaries() |-> unload_video_binaries() In unload_video_binaries(), it calls to ia_css_binary_unload with argument &pipe->pipe_settings.video.yuv_scaler_binary[i], which refers to the same memory slot as mycs->yuv_scaler_binary. Thus, a null-pointer dereference is triggered. Link: https://lore.kernel.org/r/20240118151303.3828292-1-alexious@zju.edu.cn Fixes: a49d25364dfb ("staging/atomisp: Add support for the Intel IPU v2") Signed-off-by: Zhipeng Lu Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/sh_css.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/sh_css.c b/drivers/staging/media/atomisp/pci/sh_css.c index 938a4ea89c59..8c30191b21a7 100644 --- a/drivers/staging/media/atomisp/pci/sh_css.c +++ b/drivers/staging/media/atomisp/pci/sh_css.c @@ -4690,6 +4690,7 @@ static int load_video_binaries(struct ia_css_pipe *pipe) sizeof(struct ia_css_binary), GFP_KERNEL); if (!mycs->yuv_scaler_binary) { + mycs->num_yuv_scaler = 0; err = -ENOMEM; return err; } -- cgit v1.2.3 From c1dc6f5a2774a543b5f669c88bfcc68fcdc48b5e Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sat, 3 Feb 2024 12:42:06 +0100 Subject: media: atomisp: Remove isp_subdev_propagate() isp_subdev_propagate() is a wrapper around atomisp_subdev_set_selection() which gets only used in a single place. Call atomisp_subdev_set_selection() directly in that single place instead. Reviewed-by: Kieran Bingham Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_subdev.c | 38 ++++------------------ 1 file changed, 7 insertions(+), 31 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_subdev.c b/drivers/staging/media/atomisp/pci/atomisp_subdev.c index a87fc74159e2..8293bda0c681 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_subdev.c +++ b/drivers/staging/media/atomisp/pci/atomisp_subdev.c @@ -287,35 +287,6 @@ static void isp_get_fmt_rect(struct v4l2_subdev *sd, } } -static void isp_subdev_propagate(struct v4l2_subdev *sd, - struct v4l2_subdev_state *sd_state, - u32 which, uint32_t pad, uint32_t target, - uint32_t flags) -{ - struct v4l2_mbus_framefmt *ffmt[ATOMISP_SUBDEV_PADS_NUM]; - struct v4l2_rect *crop[ATOMISP_SUBDEV_PADS_NUM], - *comp[ATOMISP_SUBDEV_PADS_NUM]; - - if (flags & V4L2_SEL_FLAG_KEEP_CONFIG) - return; - - isp_get_fmt_rect(sd, sd_state, which, ffmt, crop, comp); - - switch (pad) { - case ATOMISP_SUBDEV_PAD_SINK: { - struct v4l2_rect r = {0}; - - /* Only crop target supported on sink pad. */ - r.width = ffmt[pad]->width; - r.height = ffmt[pad]->height; - - atomisp_subdev_set_selection(sd, sd_state, which, pad, - target, flags, &r); - break; - } - } -} - static int isp_subdev_get_selection(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_selection *sel) @@ -541,6 +512,7 @@ void atomisp_subdev_set_ffmt(struct v4l2_subdev *sd, case ATOMISP_SUBDEV_PAD_SINK: { const struct atomisp_in_fmt_conv *fc = atomisp_find_in_fmt_conv(ffmt->code); + struct v4l2_rect r = {}; if (!fc) { fc = atomisp_in_fmt_conv; @@ -551,8 +523,12 @@ void atomisp_subdev_set_ffmt(struct v4l2_subdev *sd, *__ffmt = *ffmt; - isp_subdev_propagate(sd, sd_state, which, pad, - V4L2_SEL_TGT_CROP, 0); + /* Propagate new ffmt to selection */ + r.width = ffmt->width; + r.height = ffmt->height; + /* Only crop target supported on sink pad. */ + atomisp_subdev_set_selection(sd, sd_state, which, pad, + V4L2_SEL_TGT_CROP, 0, &r); if (which == V4L2_SUBDEV_FORMAT_ACTIVE) { atomisp_css_input_set_resolution(isp_sd, -- cgit v1.2.3 From ce5547e7e64a11b6b724cf6b3d13d6bf6782e03e Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Feb 2024 11:22:07 +0100 Subject: media: atomisp: Rename atomisp_set_crop_and_fmt() Rename atomisp_set_crop_and_fmt() to atomisp_set_sensor_crop_and_fmt() to make clear that it operates on the sensor subdev. Reviewed-by: Kieran Bingham Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_cmd.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp_cmd.c index 8593ba90605f..eb37bb6e41f9 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c +++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c @@ -3721,9 +3721,9 @@ apply_min_padding: *padding_h = max_t(u32, *padding_h, min_pad_h); } -static int atomisp_set_crop_and_fmt(struct atomisp_device *isp, - struct v4l2_mbus_framefmt *ffmt, - int which) +static int atomisp_set_sensor_crop_and_fmt(struct atomisp_device *isp, + struct v4l2_mbus_framefmt *ffmt, + int which) { struct atomisp_input_subdev *input = &isp->inputs[isp->asd.input_curr]; struct v4l2_subdev_selection sel = { @@ -3817,7 +3817,7 @@ int atomisp_try_fmt(struct atomisp_device *isp, struct v4l2_pix_format *f, dev_dbg(isp->dev, "try_mbus_fmt: try %ux%u\n", ffmt.width, ffmt.height); - ret = atomisp_set_crop_and_fmt(isp, &ffmt, V4L2_SUBDEV_FORMAT_TRY); + ret = atomisp_set_sensor_crop_and_fmt(isp, &ffmt, V4L2_SUBDEV_FORMAT_TRY); if (ret) return ret; @@ -4263,7 +4263,7 @@ static int atomisp_set_fmt_to_snr(struct video_device *vdev, const struct v4l2_p /* Disable dvs if resolution can't be supported by sensor */ if (asd->params.video_dis_en && asd->run_mode->val == ATOMISP_RUN_MODE_VIDEO) { - ret = atomisp_set_crop_and_fmt(isp, &ffmt, V4L2_SUBDEV_FORMAT_TRY); + ret = atomisp_set_sensor_crop_and_fmt(isp, &ffmt, V4L2_SUBDEV_FORMAT_TRY); if (ret) return ret; @@ -4281,7 +4281,7 @@ static int atomisp_set_fmt_to_snr(struct video_device *vdev, const struct v4l2_p } } - ret = atomisp_set_crop_and_fmt(isp, &ffmt, V4L2_SUBDEV_FORMAT_ACTIVE); + ret = atomisp_set_sensor_crop_and_fmt(isp, &ffmt, V4L2_SUBDEV_FORMAT_ACTIVE); if (ret) return ret; -- cgit v1.2.3 From 95146b9de7ab69fd2d799b573586a8c8a9e552b8 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Feb 2024 18:09:43 +0100 Subject: media: atomisp: Remove custom VCM handling Remove the custom VCM handling, instead the VCM should be controlled through its own v4l2-subdev and the new ipu-bridge.c code already supports instantiating an i2c_client for this and setting up the necessary endpoints in the fwnode graph. Reviewed-by: Kieran Bingham Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- .../staging/media/atomisp/include/linux/atomisp.h | 3 - .../media/atomisp/include/linux/atomisp_platform.h | 5 +- .../staging/media/atomisp/pci/atomisp_internal.h | 4 - drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 86 +--------------------- drivers/staging/media/atomisp/pci/atomisp_v4l2.c | 15 ---- 5 files changed, 3 insertions(+), 110 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/include/linux/atomisp.h b/drivers/staging/media/atomisp/include/linux/atomisp.h index bbbd904b696a..d9a7a599038d 100644 --- a/drivers/staging/media/atomisp/include/linux/atomisp.h +++ b/drivers/staging/media/atomisp/include/linux/atomisp.h @@ -914,9 +914,6 @@ enum atomisp_burst_capture_options { /* VCM step time */ #define V4L2_CID_VCM_TIMING (V4L2_CID_CAMERA_LASTP1 + 12) -/* Query Focus Status */ -#define V4L2_CID_FOCUS_STATUS (V4L2_CID_CAMERA_LASTP1 + 14) - /* number of frames to skip at stream start */ #define V4L2_CID_G_SKIP_FRAMES (V4L2_CID_CAMERA_LASTP1 + 17) diff --git a/drivers/staging/media/atomisp/include/linux/atomisp_platform.h b/drivers/staging/media/atomisp/include/linux/atomisp_platform.h index 487ef5846c24..2535402afd73 100644 --- a/drivers/staging/media/atomisp/include/linux/atomisp_platform.h +++ b/drivers/staging/media/atomisp/include/linux/atomisp_platform.h @@ -111,9 +111,8 @@ enum atomisp_input_format { enum intel_v4l2_subdev_type { RAW_CAMERA = 1, - CAMERA_MOTOR = 2, - LED_FLASH = 3, - TEST_PATTERN = 4, + LED_FLASH = 2, + TEST_PATTERN = 3, }; struct intel_v4l2_subdev_id { diff --git a/drivers/staging/media/atomisp/pci/atomisp_internal.h b/drivers/staging/media/atomisp/pci/atomisp_internal.h index bba9bc64d447..ca8ed3a6b9b8 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_internal.h +++ b/drivers/staging/media/atomisp/pci/atomisp_internal.h @@ -134,9 +134,6 @@ struct atomisp_input_subdev { struct v4l2_rect active_rect; /* Sensor state for which == V4L2_SUBDEV_FORMAT_TRY calls */ struct v4l2_subdev_state *try_sd_state; - - struct v4l2_subdev *motor; - /* * To show this resource is used by * which stream, in ISP multiple stream mode @@ -210,7 +207,6 @@ struct atomisp_device { unsigned int input_cnt; struct atomisp_input_subdev inputs[ATOM_ISP_MAX_INPUTS]; struct v4l2_subdev *flash; - struct v4l2_subdev *motor; struct atomisp_regs saved_regs; struct atomisp_css_env css_env; diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c index bb8e5e883b50..ef555054fdbf 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c +++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c @@ -557,7 +557,6 @@ static int atomisp_enum_input(struct file *file, void *fh, struct video_device *vdev = video_devdata(file); struct atomisp_device *isp = video_get_drvdata(vdev); int index = input->index; - struct v4l2_subdev *motor; if (index >= isp->input_cnt) return -EINVAL; @@ -569,28 +568,6 @@ static int atomisp_enum_input(struct file *file, void *fh, strscpy(input->name, isp->inputs[index].camera->name, sizeof(input->name)); - /* - * HACK: append actuator's name to sensor's - * As currently userspace can't talk directly to subdev nodes, this - * ioctl is the only way to enum inputs + possible external actuators - * for 3A tuning purpose. - */ - if (!IS_ISP2401) - motor = isp->inputs[index].motor; - else - motor = isp->motor; - - if (motor && strlen(motor->name) > 0) { - const int cur_len = strlen(input->name); - const int max_size = sizeof(input->name) - cur_len - 1; - - if (max_size > 1) { - input->name[cur_len] = '+'; - strscpy(&input->name[cur_len + 1], - motor->name, max_size); - } - } - input->type = V4L2_INPUT_TYPE_CAMERA; input->index = index; input->reserved[0] = isp->inputs[index].type; @@ -629,7 +606,6 @@ static int atomisp_s_input(struct file *file, void *fh, unsigned int input) struct atomisp_video_pipe *pipe = atomisp_to_video_pipe(vdev); struct atomisp_sub_device *asd = pipe->asd; struct v4l2_subdev *camera = NULL; - struct v4l2_subdev *motor; int ret; ret = atomisp_pipe_check(pipe, true); @@ -666,17 +642,6 @@ static int atomisp_s_input(struct file *file, void *fh, unsigned int input) return ret; } - if (!IS_ISP2401) { - motor = isp->inputs[input].motor; - } else { - motor = isp->motor; - if (motor) - ret = v4l2_subdev_call(motor, core, s_power, 1); - } - - if (motor) - ret = v4l2_subdev_call(motor, core, init, 1); - asd->input_curr = input; /* mark this camera is used by the current stream */ isp->inputs[input].asd = asd; @@ -1433,26 +1398,8 @@ static int atomisp_s_ctrl(struct file *file, void *fh, static int atomisp_queryctl(struct file *file, void *fh, struct v4l2_queryctrl *qc) { - int i, ret = -EINVAL; struct video_device *vdev = video_devdata(file); - struct atomisp_sub_device *asd = atomisp_to_video_pipe(vdev)->asd; - struct atomisp_device *isp = video_get_drvdata(vdev); - - switch (qc->id) { - case V4L2_CID_FOCUS_ABSOLUTE: - case V4L2_CID_FOCUS_RELATIVE: - case V4L2_CID_FOCUS_STATUS: - if (!IS_ISP2401) { - return v4l2_queryctrl(isp->inputs[asd->input_curr].camera-> - ctrl_handler, qc); - } - /* ISP2401 */ - if (isp->motor) - return v4l2_queryctrl(isp->motor->ctrl_handler, qc); - else - return v4l2_queryctrl(isp->inputs[asd->input_curr]. - camera->ctrl_handler, qc); - } + int i, ret = -EINVAL; if (qc->id & V4L2_CTRL_FLAG_NEXT_CTRL) return ret; @@ -1478,16 +1425,10 @@ static int atomisp_camera_g_ext_ctrls(struct file *file, void *fh, struct video_device *vdev = video_devdata(file); struct atomisp_sub_device *asd = atomisp_to_video_pipe(vdev)->asd; struct atomisp_device *isp = video_get_drvdata(vdev); - struct v4l2_subdev *motor; struct v4l2_control ctrl; int i; int ret = 0; - if (!IS_ISP2401) - motor = isp->inputs[asd->input_curr].motor; - else - motor = isp->motor; - for (i = 0; i < c->count; i++) { ctrl.id = c->controls[i].id; ctrl.value = c->controls[i].value; @@ -1509,13 +1450,6 @@ static int atomisp_camera_g_ext_ctrls(struct file *file, void *fh, v4l2_g_ctrl(isp->inputs[asd->input_curr].camera-> ctrl_handler, &ctrl); break; - case V4L2_CID_FOCUS_ABSOLUTE: - case V4L2_CID_FOCUS_RELATIVE: - case V4L2_CID_FOCUS_STATUS: - case V4L2_CID_FOCUS_AUTO: - if (motor) - ret = v4l2_g_ctrl(motor->ctrl_handler, &ctrl); - break; case V4L2_CID_FLASH_STATUS: case V4L2_CID_FLASH_INTENSITY: case V4L2_CID_FLASH_TORCH_INTENSITY: @@ -1584,16 +1518,10 @@ static int atomisp_camera_s_ext_ctrls(struct file *file, void *fh, struct video_device *vdev = video_devdata(file); struct atomisp_sub_device *asd = atomisp_to_video_pipe(vdev)->asd; struct atomisp_device *isp = video_get_drvdata(vdev); - struct v4l2_subdev *motor; struct v4l2_control ctrl; int i; int ret = 0; - if (!IS_ISP2401) - motor = isp->inputs[asd->input_curr].motor; - else - motor = isp->motor; - for (i = 0; i < c->count; i++) { struct v4l2_ctrl *ctr; @@ -1616,18 +1544,6 @@ static int atomisp_camera_s_ext_ctrls(struct file *file, void *fh, isp->inputs[asd->input_curr].camera-> ctrl_handler, &ctrl); break; - case V4L2_CID_FOCUS_ABSOLUTE: - case V4L2_CID_FOCUS_RELATIVE: - case V4L2_CID_FOCUS_STATUS: - case V4L2_CID_FOCUS_AUTO: - if (motor) - ret = v4l2_s_ctrl(NULL, motor->ctrl_handler, - &ctrl); - else - ret = v4l2_s_ctrl(NULL, - isp->inputs[asd->input_curr]. - camera->ctrl_handler, &ctrl); - break; case V4L2_CID_FLASH_STATUS: case V4L2_CID_FLASH_INTENSITY: case V4L2_CID_FLASH_TORCH_INTENSITY: diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c index 5a97013094f2..9a0853be0e79 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c +++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c @@ -823,13 +823,6 @@ static int atomisp_subdev_probe(struct atomisp_device *isp) isp->sensor_lanes[mipi_port] = subdevs->lanes; isp->sensor_subdevs[subdevs->port] = subdevs->subdev; break; - case CAMERA_MOTOR: - if (isp->motor) { - dev_warn(isp->dev, "too many atomisp motors\n"); - continue; - } - isp->motor = subdevs->subdev; - break; case LED_FLASH: if (isp->flash) { dev_warn(isp->dev, "too many atomisp flash devices\n"); @@ -1066,14 +1059,6 @@ int atomisp_register_device_nodes(struct atomisp_device *isp) atomisp_init_sensor(input); - /* - * HACK: Currently VCM belongs to primary sensor only, but correct - * approach must be to acquire from platform code which sensor - * owns it. - */ - if (i == ATOMISP_CAMERA_PORT_PRIMARY) - input->motor = isp->motor; - err = media_create_pad_link(&input->camera->entity, 0, &isp->csi2_port[i].subdev.entity, CSI2_PAD_SINK, -- cgit v1.2.3 From dc37768447ac52170ec039a2e92f8e9a4501bc06 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Feb 2024 23:33:25 +0100 Subject: media: atomisp: Remove ISP controls which get passed through to the camera Drop all ISP controls and ioctls which just get passed through to the camera subdev. Instead these calls should be done directly at the sensor subdev. Reviewed-by: Kieran Bingham Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- .../staging/media/atomisp/include/linux/atomisp.h | 21 -- drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 248 --------------------- 2 files changed, 269 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/include/linux/atomisp.h b/drivers/staging/media/atomisp/include/linux/atomisp.h index d9a7a599038d..b2735a008052 100644 --- a/drivers/staging/media/atomisp/include/linux/atomisp.h +++ b/drivers/staging/media/atomisp/include/linux/atomisp.h @@ -837,9 +837,6 @@ enum atomisp_burst_capture_options { #define ATOMISP_IOC_S_PARAMETERS \ _IOW('v', BASE_VIDIOC_PRIVATE + 32, struct atomisp_parameters) -#define ATOMISP_IOC_EXT_ISP_CTRL \ - _IOWR('v', BASE_VIDIOC_PRIVATE + 35, struct atomisp_ext_isp_ctrl) - #define ATOMISP_IOC_EXP_ID_UNLOCK \ _IOW('v', BASE_VIDIOC_PRIVATE + 36, int) @@ -909,19 +906,6 @@ enum atomisp_burst_capture_options { /* Set the flash mode (see enum atomisp_flash_mode) */ #define V4L2_CID_FLASH_MODE (V4L2_CID_CAMERA_LASTP1 + 10) -/* VCM slew control */ -#define V4L2_CID_VCM_SLEW (V4L2_CID_CAMERA_LASTP1 + 11) -/* VCM step time */ -#define V4L2_CID_VCM_TIMING (V4L2_CID_CAMERA_LASTP1 + 12) - -/* number of frames to skip at stream start */ -#define V4L2_CID_G_SKIP_FRAMES (V4L2_CID_CAMERA_LASTP1 + 17) - -/* Query sensor's 2A status */ -#define V4L2_CID_2A_STATUS (V4L2_CID_CAMERA_LASTP1 + 18) -#define V4L2_2A_STATUS_AE_READY BIT(0) -#define V4L2_2A_STATUS_AWB_READY BIT(1) - #define V4L2_CID_RUN_MODE (V4L2_CID_CAMERA_LASTP1 + 20) #define ATOMISP_RUN_MODE_VIDEO 1 #define ATOMISP_RUN_MODE_STILL_CAPTURE 2 @@ -952,11 +936,6 @@ enum atomisp_burst_capture_options { /* Disable digital zoom */ #define V4L2_CID_DISABLE_DZ (V4L2_CID_CAMERA_LASTP1 + 32) -#define V4L2_CID_TEST_PATTERN_COLOR_R (V4L2_CID_CAMERA_LASTP1 + 33) -#define V4L2_CID_TEST_PATTERN_COLOR_GR (V4L2_CID_CAMERA_LASTP1 + 34) -#define V4L2_CID_TEST_PATTERN_COLOR_GB (V4L2_CID_CAMERA_LASTP1 + 35) -#define V4L2_CID_TEST_PATTERN_COLOR_B (V4L2_CID_CAMERA_LASTP1 + 36) - #define V4L2_CID_ATOMISP_SELECT_ISP_VERSION (V4L2_CID_CAMERA_LASTP1 + 38) #define V4L2_BUF_FLAG_BUFFER_INVALID 0x0400 diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c index ef555054fdbf..74cf055cb09b 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c +++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c @@ -82,15 +82,6 @@ static struct v4l2_queryctrl ci_v4l2_controls[] = { .step = 1, .default_value = 0x00, }, - { - .id = V4L2_CID_POWER_LINE_FREQUENCY, - .type = V4L2_CTRL_TYPE_MENU, - .name = "Light frequency filter", - .minimum = 1, - .maximum = 2, - .step = 1, - .default_value = 1, - }, { .id = V4L2_CID_COLORFX, .type = V4L2_CTRL_TYPE_INTEGER, @@ -100,15 +91,6 @@ static struct v4l2_queryctrl ci_v4l2_controls[] = { .step = 1, .default_value = 0, }, - { - .id = V4L2_CID_COLORFX_CBCR, - .type = V4L2_CTRL_TYPE_INTEGER, - .name = "Image Color Effect CbCr", - .minimum = 0, - .maximum = 0xffff, - .step = 1, - .default_value = 0, - }, { .id = V4L2_CID_ATOMISP_BAD_PIXEL_DETECTION, .type = V4L2_CTRL_TYPE_INTEGER, @@ -172,142 +154,6 @@ static struct v4l2_queryctrl ci_v4l2_controls[] = { .step = 1, .default_value = 1, }, - { - .id = V4L2_CID_2A_STATUS, - .type = V4L2_CTRL_TYPE_BITMASK, - .name = "AE and AWB status", - .minimum = 0, - .maximum = V4L2_2A_STATUS_AE_READY | V4L2_2A_STATUS_AWB_READY, - .step = 1, - .default_value = 0, - }, - { - .id = V4L2_CID_EXPOSURE, - .type = V4L2_CTRL_TYPE_INTEGER, - .name = "exposure", - .minimum = -4, - .maximum = 4, - .step = 1, - .default_value = 0, - }, - { - .id = V4L2_CID_EXPOSURE_ZONE_NUM, - .type = V4L2_CTRL_TYPE_INTEGER, - .name = "one-time exposure zone number", - .minimum = 0x0, - .maximum = 0xffff, - .step = 1, - .default_value = 0, - }, - { - .id = V4L2_CID_EXPOSURE_AUTO_PRIORITY, - .type = V4L2_CTRL_TYPE_INTEGER, - .name = "Exposure auto priority", - .minimum = V4L2_EXPOSURE_AUTO, - .maximum = V4L2_EXPOSURE_APERTURE_PRIORITY, - .step = 1, - .default_value = V4L2_EXPOSURE_AUTO, - }, - { - .id = V4L2_CID_SCENE_MODE, - .type = V4L2_CTRL_TYPE_INTEGER, - .name = "scene mode", - .minimum = 0, - .maximum = 13, - .step = 1, - .default_value = 0, - }, - { - .id = V4L2_CID_ISO_SENSITIVITY, - .type = V4L2_CTRL_TYPE_INTEGER, - .name = "iso", - .minimum = -4, - .maximum = 4, - .step = 1, - .default_value = 0, - }, - { - .id = V4L2_CID_ISO_SENSITIVITY_AUTO, - .type = V4L2_CTRL_TYPE_INTEGER, - .name = "iso mode", - .minimum = V4L2_ISO_SENSITIVITY_MANUAL, - .maximum = V4L2_ISO_SENSITIVITY_AUTO, - .step = 1, - .default_value = V4L2_ISO_SENSITIVITY_AUTO, - }, - { - .id = V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE, - .type = V4L2_CTRL_TYPE_INTEGER, - .name = "white balance", - .minimum = 0, - .maximum = 9, - .step = 1, - .default_value = 0, - }, - { - .id = V4L2_CID_EXPOSURE_METERING, - .type = V4L2_CTRL_TYPE_MENU, - .name = "metering", - .minimum = 0, - .maximum = 3, - .step = 1, - .default_value = 1, - }, - { - .id = V4L2_CID_3A_LOCK, - .type = V4L2_CTRL_TYPE_BITMASK, - .name = "3a lock", - .minimum = 0, - .maximum = V4L2_LOCK_EXPOSURE | V4L2_LOCK_WHITE_BALANCE - | V4L2_LOCK_FOCUS, - .step = 1, - .default_value = 0, - }, - { - .id = V4L2_CID_TEST_PATTERN, - .type = V4L2_CTRL_TYPE_INTEGER, - .name = "Test Pattern", - .minimum = 0, - .maximum = 0xffff, - .step = 1, - .default_value = 0, - }, - { - .id = V4L2_CID_TEST_PATTERN_COLOR_R, - .type = V4L2_CTRL_TYPE_INTEGER, - .name = "Test Pattern Solid Color R", - .minimum = INT_MIN, - .maximum = INT_MAX, - .step = 1, - .default_value = 0, - }, - { - .id = V4L2_CID_TEST_PATTERN_COLOR_GR, - .type = V4L2_CTRL_TYPE_INTEGER, - .name = "Test Pattern Solid Color GR", - .minimum = INT_MIN, - .maximum = INT_MAX, - .step = 1, - .default_value = 0, - }, - { - .id = V4L2_CID_TEST_PATTERN_COLOR_GB, - .type = V4L2_CTRL_TYPE_INTEGER, - .name = "Test Pattern Solid Color GB", - .minimum = INT_MIN, - .maximum = INT_MAX, - .step = 1, - .default_value = 0, - }, - { - .id = V4L2_CID_TEST_PATTERN_COLOR_B, - .type = V4L2_CTRL_TYPE_INTEGER, - .name = "Test Pattern Solid Color B", - .minimum = INT_MIN, - .maximum = INT_MAX, - .step = 1, - .default_value = 0, - }, }; static const u32 ctrls_num = ARRAY_SIZE(ci_v4l2_controls); @@ -1248,7 +1094,6 @@ static int atomisp_g_ctrl(struct file *file, void *fh, { struct video_device *vdev = video_devdata(file); struct atomisp_sub_device *asd = atomisp_to_video_pipe(vdev)->asd; - struct atomisp_device *isp = video_get_drvdata(vdev); int i, ret = -EINVAL; for (i = 0; i < ctrls_num; i++) { @@ -1262,27 +1107,6 @@ static int atomisp_g_ctrl(struct file *file, void *fh, return ret; switch (control->id) { - case V4L2_CID_IRIS_ABSOLUTE: - case V4L2_CID_EXPOSURE_ABSOLUTE: - case V4L2_CID_2A_STATUS: - case V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE: - case V4L2_CID_EXPOSURE: - case V4L2_CID_EXPOSURE_AUTO: - case V4L2_CID_SCENE_MODE: - case V4L2_CID_ISO_SENSITIVITY: - case V4L2_CID_ISO_SENSITIVITY_AUTO: - case V4L2_CID_CONTRAST: - case V4L2_CID_SATURATION: - case V4L2_CID_SHARPNESS: - case V4L2_CID_3A_LOCK: - case V4L2_CID_EXPOSURE_ZONE_NUM: - case V4L2_CID_TEST_PATTERN: - case V4L2_CID_TEST_PATTERN_COLOR_R: - case V4L2_CID_TEST_PATTERN_COLOR_GR: - case V4L2_CID_TEST_PATTERN_COLOR_GB: - case V4L2_CID_TEST_PATTERN_COLOR_B: - return v4l2_g_ctrl(isp->inputs[asd->input_curr].camera-> - ctrl_handler, control); case V4L2_CID_COLORFX: ret = atomisp_color_effect(asd, 0, &control->value); break; @@ -1322,7 +1146,6 @@ static int atomisp_s_ctrl(struct file *file, void *fh, { struct video_device *vdev = video_devdata(file); struct atomisp_sub_device *asd = atomisp_to_video_pipe(vdev)->asd; - struct atomisp_device *isp = video_get_drvdata(vdev); int i, ret = -EINVAL; for (i = 0; i < ctrls_num; i++) { @@ -1336,28 +1159,6 @@ static int atomisp_s_ctrl(struct file *file, void *fh, return ret; switch (control->id) { - case V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE: - case V4L2_CID_EXPOSURE: - case V4L2_CID_EXPOSURE_AUTO: - case V4L2_CID_EXPOSURE_AUTO_PRIORITY: - case V4L2_CID_SCENE_MODE: - case V4L2_CID_ISO_SENSITIVITY: - case V4L2_CID_ISO_SENSITIVITY_AUTO: - case V4L2_CID_POWER_LINE_FREQUENCY: - case V4L2_CID_EXPOSURE_METERING: - case V4L2_CID_CONTRAST: - case V4L2_CID_SATURATION: - case V4L2_CID_SHARPNESS: - case V4L2_CID_3A_LOCK: - case V4L2_CID_COLORFX_CBCR: - case V4L2_CID_TEST_PATTERN: - case V4L2_CID_TEST_PATTERN_COLOR_R: - case V4L2_CID_TEST_PATTERN_COLOR_GR: - case V4L2_CID_TEST_PATTERN_COLOR_GB: - case V4L2_CID_TEST_PATTERN_COLOR_B: - return v4l2_s_ctrl(NULL, - isp->inputs[asd->input_curr].camera-> - ctrl_handler, control); case V4L2_CID_COLORFX: ret = atomisp_color_effect(asd, 1, &control->value); break; @@ -1398,7 +1199,6 @@ static int atomisp_s_ctrl(struct file *file, void *fh, static int atomisp_queryctl(struct file *file, void *fh, struct v4l2_queryctrl *qc) { - struct video_device *vdev = video_devdata(file); int i, ret = -EINVAL; if (qc->id & V4L2_CTRL_FLAG_NEXT_CTRL) @@ -1433,23 +1233,6 @@ static int atomisp_camera_g_ext_ctrls(struct file *file, void *fh, ctrl.id = c->controls[i].id; ctrl.value = c->controls[i].value; switch (ctrl.id) { - case V4L2_CID_EXPOSURE_ABSOLUTE: - case V4L2_CID_EXPOSURE_AUTO: - case V4L2_CID_IRIS_ABSOLUTE: - case V4L2_CID_3A_LOCK: - case V4L2_CID_TEST_PATTERN: - case V4L2_CID_TEST_PATTERN_COLOR_R: - case V4L2_CID_TEST_PATTERN_COLOR_GR: - case V4L2_CID_TEST_PATTERN_COLOR_GB: - case V4L2_CID_TEST_PATTERN_COLOR_B: - /* - * Exposure related control will be handled by sensor - * driver - */ - ret = - v4l2_g_ctrl(isp->inputs[asd->input_curr].camera-> - ctrl_handler, &ctrl); - break; case V4L2_CID_FLASH_STATUS: case V4L2_CID_FLASH_INTENSITY: case V4L2_CID_FLASH_TORCH_INTENSITY: @@ -1466,11 +1249,6 @@ static int atomisp_camera_g_ext_ctrls(struct file *file, void *fh, case V4L2_CID_ZOOM_ABSOLUTE: ret = atomisp_digital_zoom(asd, 0, &ctrl.value); break; - case V4L2_CID_G_SKIP_FRAMES: - ret = v4l2_subdev_call( - isp->inputs[asd->input_curr].camera, - sensor, g_skip_frames, (u32 *)&ctrl.value); - break; default: ret = -EINVAL; } @@ -1528,22 +1306,6 @@ static int atomisp_camera_s_ext_ctrls(struct file *file, void *fh, ctrl.id = c->controls[i].id; ctrl.value = c->controls[i].value; switch (ctrl.id) { - case V4L2_CID_EXPOSURE_ABSOLUTE: - case V4L2_CID_EXPOSURE_AUTO: - case V4L2_CID_EXPOSURE_METERING: - case V4L2_CID_IRIS_ABSOLUTE: - case V4L2_CID_VCM_TIMING: - case V4L2_CID_VCM_SLEW: - case V4L2_CID_3A_LOCK: - case V4L2_CID_TEST_PATTERN: - case V4L2_CID_TEST_PATTERN_COLOR_R: - case V4L2_CID_TEST_PATTERN_COLOR_GR: - case V4L2_CID_TEST_PATTERN_COLOR_GB: - case V4L2_CID_TEST_PATTERN_COLOR_B: - ret = v4l2_s_ctrl(NULL, - isp->inputs[asd->input_curr].camera-> - ctrl_handler, &ctrl); - break; case V4L2_CID_FLASH_STATUS: case V4L2_CID_FLASH_INTENSITY: case V4L2_CID_FLASH_TORCH_INTENSITY: @@ -1692,7 +1454,6 @@ static long atomisp_vidioc_default(struct file *file, void *fh, bool valid_prio, unsigned int cmd, void *arg) { struct video_device *vdev = video_devdata(file); - struct atomisp_device *isp = video_get_drvdata(vdev); struct atomisp_sub_device *asd = atomisp_to_video_pipe(vdev)->asd; int err; @@ -1839,11 +1600,6 @@ static long atomisp_vidioc_default(struct file *file, void *fh, err = atomisp_fixed_pattern_table(asd, arg); break; - case ATOMISP_IOC_S_EXPOSURE: - err = v4l2_subdev_call(isp->inputs[asd->input_curr].camera, - core, ioctl, cmd, arg); - break; - case ATOMISP_IOC_S_ISP_SHD_TAB: err = atomisp_set_shading_table(asd, arg); break; @@ -1860,10 +1616,6 @@ static long atomisp_vidioc_default(struct file *file, void *fh, err = atomisp_set_parameters(vdev, arg); break; - case ATOMISP_IOC_EXT_ISP_CTRL: - err = v4l2_subdev_call(isp->inputs[asd->input_curr].camera, - core, ioctl, cmd, arg); - break; case ATOMISP_IOC_EXP_ID_UNLOCK: err = atomisp_exp_id_unlock(asd, arg); break; -- cgit v1.2.3 From e4d2abc7af5e8940bc092da54be65faec97e30c4 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 28 Jan 2024 13:43:30 +0100 Subject: media: atomisp: Stop setting sd->devnode for the ATOMISP_SUBDEV v4l2-subdev Stop setting sd->devnode for the ATOMISP_SUBDEV v4l2-subdev, so that a proper /dev/v4l-subdev# gets created for it. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_subdev.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_subdev.c b/drivers/staging/media/atomisp/pci/atomisp_subdev.c index 8293bda0c681..7f1ca05ce54a 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_subdev.c +++ b/drivers/staging/media/atomisp/pci/atomisp_subdev.c @@ -802,7 +802,6 @@ static int isp_subdev_init_entities(struct atomisp_sub_device *asd) sprintf(sd->name, "ATOMISP_SUBDEV"); v4l2_set_subdevdata(sd, asd); sd->flags |= V4L2_SUBDEV_FL_HAS_EVENTS | V4L2_SUBDEV_FL_HAS_DEVNODE; - sd->devnode = &asd->video_out.vdev; pads[ATOMISP_SUBDEV_PAD_SINK].flags = MEDIA_PAD_FL_SINK; pads[ATOMISP_SUBDEV_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE; -- cgit v1.2.3 From c651e565f8b2d2b6911c1c01c529ca04bd8edd88 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Fri, 2 Feb 2024 08:37:28 +0100 Subject: media: atomisp: Add DMABUF support Add DMABUF support and while at it drop userptr support. Now that atomisp has been ported to videobuf2 this is trivial. Reviewed-by: Kieran Bingham Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 1 + drivers/staging/media/atomisp/pci/atomisp_subdev.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c index 74cf055cb09b..fa6c9f0ea6eb 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c +++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c @@ -1666,6 +1666,7 @@ const struct v4l2_ioctl_ops atomisp_ioctl_ops = { .vidioc_querybuf = vb2_ioctl_querybuf, .vidioc_qbuf = atomisp_qbuf_wrapper, .vidioc_dqbuf = atomisp_dqbuf_wrapper, + .vidioc_expbuf = vb2_ioctl_expbuf, .vidioc_streamon = vb2_ioctl_streamon, .vidioc_streamoff = vb2_ioctl_streamoff, .vidioc_default = atomisp_vidioc_default, diff --git a/drivers/staging/media/atomisp/pci/atomisp_subdev.c b/drivers/staging/media/atomisp/pci/atomisp_subdev.c index 7f1ca05ce54a..8253b6faf8cd 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_subdev.c +++ b/drivers/staging/media/atomisp/pci/atomisp_subdev.c @@ -765,7 +765,7 @@ static int atomisp_init_subdev_pipe(struct atomisp_sub_device *asd, /* Init videobuf2 queue structure */ pipe->vb_queue.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - pipe->vb_queue.io_modes = VB2_MMAP | VB2_USERPTR; + pipe->vb_queue.io_modes = VB2_MMAP | VB2_DMABUF; pipe->vb_queue.buf_struct_size = sizeof(struct ia_css_frame); pipe->vb_queue.ops = &atomisp_vb2_ops; pipe->vb_queue.mem_ops = &vb2_vmalloc_memops; -- cgit v1.2.3 From c7922162961b9e8d846e7c4cb8727c6039261393 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Feb 2024 10:50:49 +0100 Subject: media: atomisp: Change ISP subdev name to "ATOM ISP" Change the generic "ATOMISP_SUBDEV" name to "ATOM ISP" to make clear that this is the subdev for the ISP itself. Reviewed-by: Kieran Bingham Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_subdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_subdev.c b/drivers/staging/media/atomisp/pci/atomisp_subdev.c index 8253b6faf8cd..e336d3c2c289 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_subdev.c +++ b/drivers/staging/media/atomisp/pci/atomisp_subdev.c @@ -799,7 +799,7 @@ static int isp_subdev_init_entities(struct atomisp_sub_device *asd) int ret; v4l2_subdev_init(sd, &isp_subdev_v4l2_ops); - sprintf(sd->name, "ATOMISP_SUBDEV"); + sprintf(sd->name, "Atom ISP"); v4l2_set_subdevdata(sd, asd); sd->flags |= V4L2_SUBDEV_FL_HAS_EVENTS | V4L2_SUBDEV_FL_HAS_DEVNODE; -- cgit v1.2.3 From 185883b28bf66f27e854a1ea2324f645be1df640 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Feb 2024 17:41:15 +0100 Subject: media: atomisp: Make MC link from ISP to /dev/video# output node immutable The link from the ISP's source pad to the /dev/video# output v4l2-dev is always enabled and immutable, mark it as such. Reviewed-by: Kieran Bingham Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_v4l2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c index 9a0853be0e79..26020be69334 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c +++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c @@ -1090,7 +1090,8 @@ int atomisp_register_device_nodes(struct atomisp_device *isp) return err; err = media_create_pad_link(&isp->asd.subdev.entity, ATOMISP_SUBDEV_PAD_SOURCE, - &isp->asd.video_out.vdev.entity, 0, 0); + &isp->asd.video_out.vdev.entity, 0, + MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE); if (err) return err; -- cgit v1.2.3 From 71b3ed53b08d87212fbbe51bdc3bf44eb8c462f8 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Feb 2024 17:01:45 +0100 Subject: media: atomisp: Implement link_setup() op for ISP subdev MC entity The atomisp driver's Android heritage makes it weird in that even though it uses MC + subdev-s it is designed to primarily be controlled through its /dev/video# node. It implements s_input() on /dev/video# to select which sensor to use, while ignoring link_setup() calls to enable a link to another sensor. Add support for selecting the active sensor the MC way by adding link_setup() support. The implementation is a bit convoluted due to the atomisp driver's heritage. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_subdev.c | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_subdev.c b/drivers/staging/media/atomisp/pci/atomisp_subdev.c index e336d3c2c289..3b62341acc81 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_subdev.c +++ b/drivers/staging/media/atomisp/pci/atomisp_subdev.c @@ -31,6 +31,7 @@ #include "atomisp_compat.h" #include "atomisp_fops.h" #include "atomisp_internal.h" +#include "atomisp_ioctl.h" const struct atomisp_in_fmt_conv atomisp_in_fmt_conv[] = { { MEDIA_BUS_FMT_SBGGR8_1X8, 8, 8, ATOMISP_INPUT_FORMAT_RAW_8, IA_CSS_BAYER_ORDER_BGGR }, @@ -634,8 +635,59 @@ static void isp_subdev_init_params(struct atomisp_sub_device *asd) } /* media operations */ +static int atomisp_link_setup(struct media_entity *entity, + const struct media_pad *local, + const struct media_pad *remote, u32 flags) +{ + struct v4l2_subdev *sd = container_of(entity, struct v4l2_subdev, + entity); + struct atomisp_sub_device *asd = v4l2_get_subdevdata(sd); + struct atomisp_device *isp = asd->isp; + int i, csi_idx, ret; + + /* ISP's source is immutable */ + if (local != &asd->pads[ATOMISP_SUBDEV_PAD_SINK]) { + v4l2_err(sd, "Error pad %d does not support changing flags\n", + local->index); + return -EINVAL; + } + + for (csi_idx = 0; csi_idx < ATOMISP_CAMERA_NR_PORTS; csi_idx++) { + if (&isp->csi2_port[csi_idx].pads[CSI2_PAD_SOURCE] == remote) + break; + } + + if (csi_idx == ATOMISP_CAMERA_NR_PORTS) { + v4l2_err(sd, "Error cannot find CSI receiver for remote pad\n"); + return -EINVAL; + } + + /* Ignore disables, input_curr should only be updated on enables */ + if (!(flags & MEDIA_LNK_FL_ENABLED)) + return 0; + + for (i = 0; i < isp->input_cnt; i++) { + if (isp->inputs[i].camera == isp->sensor_subdevs[csi_idx]) + break; + } + + if (i == isp->input_cnt) { + v4l2_err(sd, "Error no sensor for CSI receiver %d\n", csi_idx); + return -EINVAL; + } + + mutex_lock(&isp->mutex); + ret = atomisp_pipe_check(&asd->video_out, true); + if (ret == 0) + asd->input_curr = i; + mutex_unlock(&isp->mutex); + + return ret; +} + static const struct media_entity_operations isp_subdev_media_ops = { .link_validate = v4l2_subdev_link_validate, + .link_setup = atomisp_link_setup, /* .set_power = v4l2_subdev_set_power, */ }; -- cgit v1.2.3 From e490d3ee39da707e4eafed9c1b48749c7e4e7782 Mon Sep 17 00:00:00 2001 From: Sakari Ailus Date: Thu, 11 Apr 2024 09:54:04 +0300 Subject: media: staging: ipu3-imgu: Update firmware path Use the current firmware path in linux-firmware repository. Check the older paths still in order to avoid causing issues to the users. Signed-off-by: Sakari Ailus Signed-off-by: Hans Verkuil --- drivers/staging/media/ipu3/ipu3-css-fw.c | 4 +++- drivers/staging/media/ipu3/ipu3-css-fw.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/ipu3/ipu3-css-fw.c b/drivers/staging/media/ipu3/ipu3-css-fw.c index 2b659b0ccca1..37482b626c3c 100644 --- a/drivers/staging/media/ipu3/ipu3-css-fw.c +++ b/drivers/staging/media/ipu3/ipu3-css-fw.c @@ -117,7 +117,9 @@ int imgu_css_fw_init(struct imgu_css *css) unsigned int i, j, binary_nr; int r; - r = request_firmware(&css->fw, IMGU_FW_NAME_20161208, css->dev); + r = request_firmware(&css->fw, IMGU_FW_NAME_IPU_20161208, css->dev); + if (r == -ENOENT) + r = request_firmware(&css->fw, IMGU_FW_NAME_20161208, css->dev); if (r == -ENOENT) r = request_firmware(&css->fw, IMGU_FW_NAME, css->dev); if (r) diff --git a/drivers/staging/media/ipu3/ipu3-css-fw.h b/drivers/staging/media/ipu3/ipu3-css-fw.h index f9403da75785..c956aa21df25 100644 --- a/drivers/staging/media/ipu3/ipu3-css-fw.h +++ b/drivers/staging/media/ipu3/ipu3-css-fw.h @@ -9,6 +9,8 @@ #define IMGU_FW_NAME "intel/ipu3-fw.bin" #define IMGU_FW_NAME_20161208 \ "intel/irci_irci_ecr-master_20161208_0213_20170112_1500.bin" +#define IMGU_FW_NAME_IPU_20161208 \ + "intel/ipu/irci_irci_ecr-master_20161208_0213_20170112_1500.bin" typedef u32 imgu_fw_ptr; -- cgit v1.2.3 From 8c40fa0bf74f61d9f007f5e4f11354c5d6269a7c Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sat, 16 Mar 2024 21:41:29 +0000 Subject: media: atomisp: Drop second V4L2_PIX_FMT_UYVY atomisp_output_fmts[] entry Some userspace apps (e.g. libcamera) do not like it if the enum_fmts ioctl returns the same fmt twice. Drop the second "do not use" V4L2_PIX_FMT_UYVY entry for parallel sensors to fix this. The current atomisp code does not support anything other then raw bayer sensors anyways, so dropping this is not an issue. Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c index fa6c9f0ea6eb..6009b7779f13 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c +++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c @@ -222,12 +222,6 @@ const struct atomisp_format_bridge atomisp_output_fmts[] = { .mbus_code = MEDIA_BUS_FMT_UYVY8_1X16, .sh_fmt = IA_CSS_FRAME_FORMAT_UYVY, .description = "UYVY, interleaved" - }, { /* This one is for parallel sensors! DO NOT USE! */ - .pixelformat = V4L2_PIX_FMT_UYVY, - .depth = 16, - .mbus_code = MEDIA_BUS_FMT_UYVY8_2X8, - .sh_fmt = IA_CSS_FRAME_FORMAT_UYVY, - .description = "UYVY, interleaved" }, { .pixelformat = V4L2_PIX_FMT_SBGGR16, .depth = 16, -- cgit v1.2.3 From c01ece4cbbb47947a6ad31933960b51e5e4c56a7 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sat, 16 Mar 2024 21:48:30 +0000 Subject: media: atomisp: Replace V4L2_PIX_FMT_RGB32 with V4L2_PIX_FMT_RGBX32 V4L2_PIX_FMT_RGB32 is deprecated because its definition never made clear if the 4th byte was alpha data or unused. Instead either V4L2_PIX_FMT_ARGB32 or V4L2_PIX_FMT_RGBX32 should be used. V4L2_PIX_FMT_RGB32 internally is mapped to IA_CSS_FRAME_FORMAT_RGBA888 and ia_css_frame_format.h says that the alpha bits there are unused, so replace V4L2_PIX_FMT_RGB32 with V4L2_PIX_FMT_RGBX32. Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_cmd.c | 4 ++-- drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp_cmd.c index eb37bb6e41f9..2bf71940050b 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c +++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c @@ -1123,7 +1123,7 @@ v4l2_fmt_to_sh_fmt(u32 fmt) return IA_CSS_FRAME_FORMAT_YUYV; case V4L2_PIX_FMT_RGB24: return IA_CSS_FRAME_FORMAT_PLANAR_RGB888; - case V4L2_PIX_FMT_RGB32: + case V4L2_PIX_FMT_RGBX32: return IA_CSS_FRAME_FORMAT_RGBA888; case V4L2_PIX_FMT_RGB565: return IA_CSS_FRAME_FORMAT_RGB565; @@ -1210,7 +1210,7 @@ u32 atomisp_get_pixel_depth(u32 pixelformat) case V4L2_PIX_FMT_RGB24: case V4L2_PIX_FMT_YUV444: return 24; - case V4L2_PIX_FMT_RGB32: + case V4L2_PIX_FMT_RGBX32: return 32; case V4L2_PIX_FMT_JPEG: case V4L2_PIX_FMT_CUSTOM_M10MO_RAW: diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c index 6009b7779f13..9d87213a8382 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c +++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c @@ -301,7 +301,7 @@ const struct atomisp_format_bridge atomisp_output_fmts[] = { .sh_fmt = IA_CSS_FRAME_FORMAT_RAW, .description = "Bayer 12" }, { - .pixelformat = V4L2_PIX_FMT_RGB32, + .pixelformat = V4L2_PIX_FMT_RGBX32, .depth = 32, .mbus_code = V4L2_MBUS_FMT_CUSTOM_RGB32, .sh_fmt = IA_CSS_FRAME_FORMAT_RGBA888, -- cgit v1.2.3 From 455132315ed50ed615bd3a45797ac9e9f8a941e5 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sat, 16 Mar 2024 21:53:06 +0000 Subject: media: atomisp: Disable broken V4L2_PIX_FMT_RGBX32 output support Disable V4L2_PIX_FMT_RGBX32 support, because it is broken. Selecting V4L2_PIX_FMT_RGBX32 output shows vertical columns with random data. For each 128 pixels in a row the last 28 (32?) or so pixels contain random data. Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c index 9d87213a8382..756f70ac073b 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c +++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c @@ -300,12 +300,6 @@ const struct atomisp_format_bridge atomisp_output_fmts[] = { .mbus_code = MEDIA_BUS_FMT_SRGGB12_1X12, .sh_fmt = IA_CSS_FRAME_FORMAT_RAW, .description = "Bayer 12" - }, { - .pixelformat = V4L2_PIX_FMT_RGBX32, - .depth = 32, - .mbus_code = V4L2_MBUS_FMT_CUSTOM_RGB32, - .sh_fmt = IA_CSS_FRAME_FORMAT_RGBA888, - .description = "32 RGB 8-8-8-8" }, { .pixelformat = V4L2_PIX_FMT_RGB565, .depth = 16, @@ -313,6 +307,17 @@ const struct atomisp_format_bridge atomisp_output_fmts[] = { .sh_fmt = IA_CSS_FRAME_FORMAT_RGB565, .description = "16 RGB 5-6-5" #if 0 + }, { + /* + * Broken, showing vertical columns with random data. + * For each 128 pixels in a row the last 28 (32?) or so pixels + * contain random data. + */ + .pixelformat = V4L2_PIX_FMT_RGBX32, + .depth = 32, + .mbus_code = V4L2_MBUS_FMT_CUSTOM_RGB32, + .sh_fmt = IA_CSS_FRAME_FORMAT_RGBA888, + .description = "32 RGB 8-8-8-8" }, { .pixelformat = V4L2_PIX_FMT_JPEG, .depth = 8, -- cgit v1.2.3 From 153d69d26f8ea90775ca7800a222845f95039b22 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 17 Mar 2024 21:45:25 +0000 Subject: media: atomisp: Initialize sequence counters to 0 instead of -1 When starting a new stream initialize the sequence counters to 0 instead of -1. This fixes the following libcamera warning: Zero sequence expected for first frame (got 4294967295) Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c index 756f70ac073b..d602bda134f9 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c +++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c @@ -954,9 +954,9 @@ int atomisp_start_streaming(struct vb2_queue *vq, unsigned int count) spin_lock_irqsave(&isp->lock, irqflags); asd->streaming = true; spin_unlock_irqrestore(&isp->lock, irqflags); - atomic_set(&asd->sof_count, -1); - atomic_set(&asd->sequence, -1); - atomic_set(&asd->sequence_temp, -1); + atomic_set(&asd->sof_count, 0); + atomic_set(&asd->sequence, 0); + atomic_set(&asd->sequence_temp, 0); asd->params.dis_proj_data_valid = false; asd->latest_preview_exp_id = 0; -- cgit v1.2.3 From ab8504731611b2cb9de156cae617139ef751e056 Mon Sep 17 00:00:00 2001 From: Jonathan Bergh Date: Sun, 25 Feb 2024 12:03:50 +0000 Subject: media: staging: media: atomisp: Fix various formatting issues and remove unneccesary braces This patch fixes the following formatting issues: * Fix various misaligned * and */ in multiline block comments * Remove unnecessary braces from single line conditional statements * Remove repeated word "from" from comment Link: https://lore.kernel.org/r/20240225120350.31226-1-bergh.jonathan@gmail.com Signed-off-by: Jonathan Bergh Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_cmd.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp_cmd.c index 2bf71940050b..3a56cf68b688 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c +++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c @@ -65,7 +65,8 @@ * At 15fps this means 133ms. We set the timeout a bit longer. * Each flash driver is supposed to set its own timeout, but * just in case someone else changed the timeout, we set it - * here to make sure we don't damage the flash hardware. */ + * here to make sure we don't damage the flash hardware. + */ #define FLASH_TIMEOUT 800 /* ms */ union host { @@ -1261,11 +1262,11 @@ int atomisp_gdc_cac(struct atomisp_sub_device *asd, int flag, } asd->params.gdc_cac_en = !!*value; - if (asd->params.gdc_cac_en) { + if (asd->params.gdc_cac_en) asd->params.config.morph_table = asd->params.css_param.morph_table; - } else { + else asd->params.config.morph_table = NULL; - } + asd->params.css_update_params_needed = true; atomisp_update_capture_mode(asd); return 0; @@ -3035,8 +3036,8 @@ void atomisp_handle_parameter_and_buffer(struct atomisp_video_pipe *pipe) } /* -* Function to configure ISP parameters -*/ + * Function to configure ISP parameters + */ int atomisp_set_parameters(struct video_device *vdev, struct atomisp_parameters *arg) { @@ -3367,7 +3368,7 @@ int atomisp_fixed_pattern(struct atomisp_sub_device *asd, int flag, return 0; } - /* Add function to get black from from sensor with shutter off */ + /* Add function to get black from sensor with shutter off */ return 0; } -- cgit v1.2.3 From a5aa36b0d506342f376b770b34746946b6cacae7 Mon Sep 17 00:00:00 2001 From: Jonathan Bergh Date: Sun, 25 Feb 2024 15:53:59 +0000 Subject: media: staging: media: atomisp: Fix formatting issues and minor code issue This patch fixes the following code style and formatting issues: * Ensure multiline block comments are correctly formatted * Remove extra braces not required for single line conditional statements Link: https://lore.kernel.org/r/20240225155359.41435-1-bergh.jonathan@gmail.com Signed-off-by: Jonathan Bergh Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 7 +++---- drivers/staging/media/atomisp/pci/atomisp_subdev.c | 7 ++++--- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c index 139ad7ad1dcf..804ffff245f3 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c @@ -1416,13 +1416,12 @@ static int gmin_get_config_var(struct device *maindev, if (efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE)) status = efi.get_variable(var16, &GMIN_CFG_VAR_EFI_GUID, NULL, (unsigned long *)out_len, out); - if (status == EFI_SUCCESS) { + if (status == EFI_SUCCESS) dev_info(maindev, "found EFI entry for '%s'\n", var8); - } else if (is_gmin) { + else if (is_gmin) dev_info(maindev, "Failed to find EFI gmin variable %s\n", var8); - } else { + else dev_info(maindev, "Failed to find EFI variable %s\n", var8); - } return ret; } diff --git a/drivers/staging/media/atomisp/pci/atomisp_subdev.c b/drivers/staging/media/atomisp/pci/atomisp_subdev.c index 3b62341acc81..c36aae69d6f7 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_subdev.c +++ b/drivers/staging/media/atomisp/pci/atomisp_subdev.c @@ -362,11 +362,12 @@ int atomisp_subdev_set_selection(struct v4l2_subdev *sd, if (isp_sd->params.video_dis_en && isp_sd->run_mode->val == ATOMISP_RUN_MODE_VIDEO) { - /* This resolution contains 20 % of DVS slack + /* + * This resolution contains 20 % of DVS slack * (of the desired captured image before * scaling, or 1 / 6 of what we get from the - * sensor) in both width and height. Remove - * it. */ + * sensor) in both width and height. Remove it. + */ crop[pad]->width = roundup(crop[pad]->width * 5 / 6, ATOM_ISP_STEP_WIDTH); crop[pad]->height = roundup(crop[pad]->height * 5 / 6, -- cgit v1.2.3 From 0a8b308bdf70b887b6012e24a47e29d30c9f2730 Mon Sep 17 00:00:00 2001 From: Jonathan Bergh Date: Mon, 26 Feb 2024 19:40:18 +0000 Subject: media: staging: media: atomisp: Remove unnecessary braces from single line conditional statements This patch does the following things: * Tidies up code in several places where braces were used in conjunction with single line conditional statements Link: https://lore.kernel.org/r/20240226194023.69070-2-bergh.jonathan@gmail.com Signed-off-by: Jonathan Bergh Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/sh_css_sp.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/sh_css_sp.c b/drivers/staging/media/atomisp/pci/sh_css_sp.c index cd7f5a3fecaa..e0e1405dfc69 100644 --- a/drivers/staging/media/atomisp/pci/sh_css_sp.c +++ b/drivers/staging/media/atomisp/pci/sh_css_sp.c @@ -420,9 +420,8 @@ sh_css_copy_buffer_attr_to_spbuffer(struct ia_css_buffer_sp *dest_buf, lines below. In order to satisfy KW an additional if has been added. This one will always yield true. */ - if ((queue_id < SH_CSS_MAX_NUM_QUEUES)) { + if ((queue_id < SH_CSS_MAX_NUM_QUEUES)) dest_buf->buf_src.queue_id = queue_id; - } } else { assert(xmem_addr != mmgr_EXCEPTION); dest_buf->buf_src.xmem_addr = xmem_addr; @@ -860,9 +859,9 @@ initialize_isp_states(const struct ia_css_binary *binary) if (!binary->info->mem_offsets.offsets.state) return; - for (i = 0; i < IA_CSS_NUM_STATE_IDS; i++) { + + for (i = 0; i < IA_CSS_NUM_STATE_IDS; i++) ia_css_kernel_init_state[i](binary); - } } static void @@ -878,9 +877,9 @@ initialize_stage_frames(struct ia_css_frames_sp *frames) unsigned int i; initialize_frame_buffer_attribute(&frames->in.buf_attr); - for (i = 0; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++) { + for (i = 0; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++) initialize_frame_buffer_attribute(&frames->out[i].buf_attr); - } + initialize_frame_buffer_attribute(&frames->out_vf.buf_attr); initialize_frame_buffer_attribute(&frames->s3a_buf); initialize_frame_buffer_attribute(&frames->dvs_buf); @@ -1269,9 +1268,9 @@ sh_css_sp_init_pipeline(struct ia_css_pipeline *me, pipe = find_pipe_by_num(pipe_num); assert(pipe); - if (!pipe) { + if (!pipe) return; - } + sh_css_sp_group.pipe[thread_id].scaler_pp_lut = sh_css_pipe_get_pp_gdc_lut(pipe); if (md_info && md_info->size > 0) { -- cgit v1.2.3 From cf410032495877a13de5988a0b97835be2999957 Mon Sep 17 00:00:00 2001 From: Jonathan Bergh Date: Mon, 26 Feb 2024 19:40:19 +0000 Subject: media: staging: media: atomisp: Fixed "unsigned int *" rather than "unsigned *" declaration in variable declaration This code fixes a code style issue where: * Checkpatch suggests using "unsigned int *" rather than a bare "unsigned *" declaration in the code Link: https://lore.kernel.org/r/20240226194023.69070-3-bergh.jonathan@gmail.com Signed-off-by: Jonathan Bergh Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/sh_css_sp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/sh_css_sp.c b/drivers/staging/media/atomisp/pci/sh_css_sp.c index e0e1405dfc69..05b9c9ea0a21 100644 --- a/drivers/staging/media/atomisp/pci/sh_css_sp.c +++ b/drivers/staging/media/atomisp/pci/sh_css_sp.c @@ -187,7 +187,7 @@ sh_css_sp_get_debug_state(struct sh_css_sp_debug_state *state) (void)HIVE_ADDR_sp_output; /* To get rid of warning in CRUN */ for (i = 0; i < sizeof(*state) / sizeof(int); i++) - ((unsigned *)state)[i] = load_sp_array_uint(sp_output, i + offset); + ((unsigned int *)state)[i] = load_sp_array_uint(sp_output, i + offset); } #endif -- cgit v1.2.3 From 505d92d7060946a317dea6974ddb3c821bf0fa73 Mon Sep 17 00:00:00 2001 From: Jonathan Bergh Date: Mon, 26 Feb 2024 19:40:20 +0000 Subject: media: staging: media: atomisp: Ensure trailing statements are on a newline and remove spurious whitespaces This patch fixes the following minor code style issues: * Ensure trailing statements are located on a newline * Removes an instance of a spurious whitespace following a conditional statement Link: https://lore.kernel.org/r/20240226194023.69070-4-bergh.jonathan@gmail.com Signed-off-by: Jonathan Bergh Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/sh_css_sp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/sh_css_sp.c b/drivers/staging/media/atomisp/pci/sh_css_sp.c index 05b9c9ea0a21..273955f5128d 100644 --- a/drivers/staging/media/atomisp/pci/sh_css_sp.c +++ b/drivers/staging/media/atomisp/pci/sh_css_sp.c @@ -732,7 +732,8 @@ sh_css_sp_write_frame_pointers(const struct sh_css_binary_args *args) /* we don't pass this error back to the upper layer, so we add a assert here because we actually hit the error here but it still works by accident... */ - if (err) assert(false); + if (err) + assert(false); return err; } @@ -747,7 +748,8 @@ sh_css_sp_init_group(bool two_ppc, sh_css_sp_group.config.no_isp_sync = (uint8_t)no_isp_sync; /* decide whether the frame is processed online or offline */ - if (if_config_index == SH_CSS_IF_CONFIG_NOT_NEEDED) return; + if (if_config_index == SH_CSS_IF_CONFIG_NOT_NEEDED) + return; if (!IS_ISP2401) { assert(if_config_index < SH_CSS_MAX_IF_CONFIGS); -- cgit v1.2.3 From 5d076c5e701564d4730a5b310d55104a822c225d Mon Sep 17 00:00:00 2001 From: Jonathan Bergh Date: Mon, 26 Feb 2024 19:40:21 +0000 Subject: media: staging: media: atomisp: Remove unnecessary parentheses from conditional statement This patch makes the following changes: * Removes additional, unnecessary parentheses from a conditional "if" statement Link: https://lore.kernel.org/r/20240226194023.69070-5-bergh.jonathan@gmail.com Signed-off-by: Jonathan Bergh Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/sh_css_sp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/sh_css_sp.c b/drivers/staging/media/atomisp/pci/sh_css_sp.c index 273955f5128d..aaa84b5d46cb 100644 --- a/drivers/staging/media/atomisp/pci/sh_css_sp.c +++ b/drivers/staging/media/atomisp/pci/sh_css_sp.c @@ -420,7 +420,7 @@ sh_css_copy_buffer_attr_to_spbuffer(struct ia_css_buffer_sp *dest_buf, lines below. In order to satisfy KW an additional if has been added. This one will always yield true. */ - if ((queue_id < SH_CSS_MAX_NUM_QUEUES)) + if (queue_id < SH_CSS_MAX_NUM_QUEUES) dest_buf->buf_src.queue_id = queue_id; } else { assert(xmem_addr != mmgr_EXCEPTION); -- cgit v1.2.3 From 8654983cdd213c4fdcbda870bafd68d5a407e299 Mon Sep 17 00:00:00 2001 From: Jonathan Bergh Date: Mon, 26 Feb 2024 19:40:22 +0000 Subject: media: staging: media: atomisp: Remove unneeded return statement from void function This patch makes the following change: * Removes an unnecessary 'return' statement from a void function implementation Link: https://lore.kernel.org/r/20240226194023.69070-6-bergh.jonathan@gmail.com Signed-off-by: Jonathan Bergh Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/sh_css_sp.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/sh_css_sp.c b/drivers/staging/media/atomisp/pci/sh_css_sp.c index aaa84b5d46cb..123937a22118 100644 --- a/drivers/staging/media/atomisp/pci/sh_css_sp.c +++ b/drivers/staging/media/atomisp/pci/sh_css_sp.c @@ -642,8 +642,6 @@ void sh_css_sp_set_if_configs( *config_b; sh_css_sp_group.config.input_formatter.b_changed = true; } - - return; } void -- cgit v1.2.3 From 80b685e677f67fc176e05d69a62ba0e4930c8244 Mon Sep 17 00:00:00 2001 From: Jonathan Bergh Date: Mon, 26 Feb 2024 19:40:23 +0000 Subject: media: staging: media: atomisp: Remove old commented code and fix multiple block comment style This patch fixes the following minor code and code style issues: * Removes a block of commented out (unused) code from the src * Reformats various multiline block comments to meet the kernel code style guidelines for block comments Link: https://lore.kernel.org/r/20240226194023.69070-7-bergh.jonathan@gmail.com Signed-off-by: Jonathan Bergh Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/sh_css_sp.c | 88 +++++++++++++++------------ 1 file changed, 49 insertions(+), 39 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/sh_css_sp.c b/drivers/staging/media/atomisp/pci/sh_css_sp.c index 123937a22118..55f9c89c6932 100644 --- a/drivers/staging/media/atomisp/pci/sh_css_sp.c +++ b/drivers/staging/media/atomisp/pci/sh_css_sp.c @@ -108,11 +108,6 @@ copy_isp_stage_to_sp_stage(void) sh_css_isp_stage.binary_info.iterator.row_stripes_overlap_lines; sh_css_sp_stage.top_cropping = (uint16_t) sh_css_isp_stage.binary_info.pipeline.top_cropping; - /* moved to sh_css_sp_init_stage - sh_css_sp_stage.enable.vf_output = - sh_css_isp_stage.binary_info.enable.vf_veceven || - sh_css_isp_stage.binary_info.num_output_pins > 1; - */ sh_css_sp_stage.enable.sdis = sh_css_isp_stage.binary_info.enable.dis; sh_css_sp_stage.enable.s3a = sh_css_isp_stage.binary_info.enable.s3a; } @@ -411,14 +406,15 @@ sh_css_copy_buffer_attr_to_spbuffer(struct ia_css_buffer_sp *dest_buf, */ assert(queue_id < SH_CSS_MAX_NUM_QUEUES); - /* Klocwork assumes assert can be disabled; - Since we can get there with any type, and it does not - know that frame_in->dynamic_data_index can only be set - for one of the types in the assert) it has to assume we - can get here for any type. however this could lead to an - out of bounds reference when indexing buf_type about 10 - lines below. In order to satisfy KW an additional if - has been added. This one will always yield true. + /* + * Klocwork assumes assert can be disabled; + * Since we can get there with any type, and it does not + * know that frame_in->dynamic_data_index can only be set + * for one of the types in the assert) it has to assume we + * can get here for any type. however this could lead to an + * out of bounds reference when indexing buf_type about 10 + * lines below. In order to satisfy KW an additional if + * has been added. This one will always yield true. */ if (queue_id < SH_CSS_MAX_NUM_QUEUES) dest_buf->buf_src.queue_id = queue_id; @@ -514,7 +510,8 @@ sh_css_copy_frame_to_spframe(struct ia_css_frame_sp *sp_frame_out, frame_in->planes.binary.data.offset; break; default: - /* This should not happen, but in case it does, + /* + * This should not happen, but in case it does, * nullify the planes */ memset(&sp_frame_out->planes, 0, sizeof(sp_frame_out->planes)); @@ -951,9 +948,10 @@ sh_css_sp_init_stage(struct ia_css_binary *binary, sh_css_sp_stage.isp_copy_output = (uint8_t)args->copy_output; sh_css_sp_stage.enable.vf_output = (args->out_vf_frame != NULL); - /* Copy the frame infos first, to be overwritten by the frames, - if these are present. - */ + /* + * Copy the frame infos first, to be overwritten by the frames, + * if these are present. + */ sh_css_sp_stage.frames.effective_in_res.width = binary->effective_in_frame_res.width; sh_css_sp_stage.frames.effective_in_res.height = binary->effective_in_frame_res.height; @@ -1030,10 +1028,12 @@ sh_css_sp_init_stage(struct ia_css_binary *binary, initialize_isp_states(binary); - /* we do this only for preview pipe because in fill_binary_info function + /* + * We do this only for preview pipe because in fill_binary_info function * we assign vf_out res to out res, but for ISP internal processing, we need * the original out res. for video pipe, it has two output pins --- out and - * vf_out, so it can keep these two resolutions already. */ + * vf_out, so it can keep these two resolutions already. + */ if (binary->info->sp.pipeline.mode == IA_CSS_BINARY_MODE_PREVIEW && (binary->vf_downscale_log2 > 0)) { /* TODO: Remove this after preview output decimation is fixed @@ -1069,20 +1069,23 @@ sp_init_stage(struct ia_css_pipeline_stage *stage, */ const char *binary_name = ""; const struct ia_css_binary_xinfo *info = NULL; - /* note: the var below is made static as it is quite large; - if it is not static it ends up on the stack which could - cause issues for drivers - */ + /* + * Note: the var below is made static as it is quite large; + * if it is not static it ends up on the stack which could + * cause issues for drivers + */ static struct ia_css_binary tmp_binary; const struct ia_css_blob_info *blob_info = NULL; struct ia_css_isp_param_css_segments isp_mem_if; - /* LA: should be ia_css_data, should not contain host pointer. - However, CSS/DDR pointer is not available yet. - Hack is to store it in params->ddr_ptrs and then copy it late in the SP just before vmem init. - TODO: Call this after CSS/DDR allocation and store that pointer. - Best is to allocate it at stage creation time together with host pointer. - Remove vmem from params. - */ + /* + * LA: should be ia_css_data, should not contain host pointer. + * However, CSS/DDR pointer is not available yet. + * Hack is to store it in params->ddr_ptrs and then copy it late in + * the SP just before vmem init. + * TODO: Call this after CSS/DDR allocation and store that pointer. + * Best is to allocate it at stage creation time together with host + * pointer. Remove vmem from params. + */ struct ia_css_isp_param_css_segments *mem_if = &isp_mem_if; int err = 0; @@ -1122,10 +1125,12 @@ sp_init_stage(struct ia_css_pipeline_stage *stage, } else { /* SP stage */ assert(stage->sp_func != IA_CSS_PIPELINE_NO_FUNC); - /* binary and blob_info are now NULL. - These will be passed to sh_css_sp_init_stage - and dereferenced there, so passing a NULL - pointer is no good. return an error */ + /* + * binary and blob_info are now NULL. + * These will be passed to sh_css_sp_init_stage + * and dereferenced there, so passing a NULL + * pointer is no good. return an error + */ return -EINVAL; } @@ -1259,8 +1264,10 @@ sh_css_sp_init_pipeline(struct ia_css_pipeline *me, SH_CSS_PIPE_CONFIG_SAMPLE_PARAMS << thread_id; } - /* For continuous use-cases, SP copy is responsible for sampling the - * parameters */ + /* + * For continuous use-cases, SP copy is responsible for sampling the + * parameters + */ if (continuous) sh_css_sp_group.pipe[thread_id].pipe_config = 0; @@ -1542,7 +1549,8 @@ ia_css_pipe_set_irq_mask(struct ia_css_pipe *pipe, assert(pipe); assert(IA_CSS_PIPE_ID_NUM == NR_OF_PIPELINES); - /* Linux kernel does not have UINT16_MAX + /* + * Linux kernel does not have UINT16_MAX * Therefore decided to comment out these 2 asserts for Linux * Alternatives that were not chosen: * - add a conditional #define for UINT16_MAX @@ -1641,7 +1649,8 @@ sh_css_sp_start_isp(void) (unsigned int)sp_address_of(sp_sw_state), (uint32_t)(IA_CSS_SP_SW_TERMINATED)); - /* Note 1: The sp_start_isp function contains a wait till + /* + * Note 1: The sp_start_isp function contains a wait till * the input network is configured by the SP. * Note 2: Not all SP binaries supports host2sp_commands. * In case a binary does support it, the host2sp_command @@ -1651,7 +1660,8 @@ sh_css_sp_start_isp(void) * received, the SP starts configuring the input network. */ - /* we need to set sp_running before we call ia_css_mmu_invalidate_cache + /* + * We need to set sp_running before we call ia_css_mmu_invalidate_cache * as ia_css_mmu_invalidate_cache checks on sp_running to * avoid that it accesses dmem while the SP is not powered */ -- cgit v1.2.3 From 8daa7c5cfbb2a3e2372573da4b6d65963645a52a Mon Sep 17 00:00:00 2001 From: Jonathan Bergh Date: Tue, 27 Feb 2024 16:30:41 +0000 Subject: media: staging: media: atomisp: Fix various multiline block comment formatting instances This patch makes the following fixes: * Reformats a number of multiline block comments to ensure * and */ align correctly Link: https://lore.kernel.org/r/20240227163043.112162-1-bergh.jonathan@gmail.com Signed-off-by: Jonathan Bergh Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_v4l2.c | 34 +++++++++++++----------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c index 26020be69334..f672b49d1844 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c +++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c @@ -74,13 +74,15 @@ static char firmware_name[256]; module_param_string(firmware_name, firmware_name, sizeof(firmware_name), 0); MODULE_PARM_DESC(firmware_name, "Firmware file name. Allows overriding the default firmware name."); -/*set to 16x16 since this is the amount of lines and pixels the sensor -exports extra. If these are kept at the 10x8 that they were on, in yuv -downscaling modes incorrect resolutions where requested to the sensor -driver with strange outcomes as a result. The proper way tot do this -would be to have a list of tables the specify the sensor res, mipi rec, -output res, and isp output res. however since we do not have this yet, -the chosen solution is the next best thing. */ +/* + * Set to 16x16 since this is the amount of lines and pixels the sensor + * exports extra. If these are kept at the 10x8 that they were on, in yuv + * downscaling modes incorrect resolutions where requested to the sensor + * driver with strange outcomes as a result. The proper way tot do this + * would be to have a list of tables the specify the sensor res, mipi rec, + * output res, and isp output res. however since we do not have this yet, + * the chosen solution is the next best thing. + */ int pad_w = 16; module_param(pad_w, int, 0644); MODULE_PARM_DESC(pad_w, "extra data for ISP processing"); @@ -503,12 +505,12 @@ static int atomisp_mrfld_pre_power_down(struct atomisp_device *isp) } done: /* - * MRFLD WORKAROUND: - * before powering off IUNIT, clear the pending interrupts - * and disable the interrupt. driver should avoid writing 0 - * to IIR. It could block subsequent interrupt messages. - * HW sighting:4568410. - */ + * MRFLD WORKAROUND: + * before powering off IUNIT, clear the pending interrupts + * and disable the interrupt. driver should avoid writing 0 + * to IIR. It could block subsequent interrupt messages. + * HW sighting:4568410. + */ pci_read_config_dword(pdev, PCI_INTERRUPT_CTRL, &irq); irq &= ~BIT(INTR_IER); pci_write_config_dword(pdev, PCI_INTERRUPT_CTRL, irq); @@ -521,9 +523,9 @@ done: } /* -* WA for DDR DVFS enable/disable -* By default, ISP will force DDR DVFS 1600MHz before disable DVFS -*/ + * WA for DDR DVFS enable/disable + * By default, ISP will force DDR DVFS 1600MHz before disable DVFS + */ static void punit_ddr_dvfs_enable(bool enable) { int reg; -- cgit v1.2.3 From 11213170617e1bb7c928e1c0fb901da877d05901 Mon Sep 17 00:00:00 2001 From: Jonathan Bergh Date: Tue, 27 Feb 2024 16:30:42 +0000 Subject: media: staging: media: atomisp: Remove extra whitespace after opening parentheses This patch makes the following changes: * Removes spurious whitespace after the opening parentheses as per code style guidelines Link: https://lore.kernel.org/r/20240227163043.112162-2-bergh.jonathan@gmail.com Signed-off-by: Jonathan Bergh Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_v4l2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c index f672b49d1844..7f702b151704 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c +++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c @@ -1313,7 +1313,7 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i pdev->d3cold_delay = 0; break; case ATOMISP_PCI_DEVICE_SOC_ANN: - isp->media_dev.hw_revision = ( ATOMISP_HW_REVISION_ISP2401 + isp->media_dev.hw_revision = (ATOMISP_HW_REVISION_ISP2401 << ATOMISP_HW_REVISION_SHIFT); isp->media_dev.hw_revision |= pdev->revision < 2 ? ATOMISP_HW_STEPPING_A0 : ATOMISP_HW_STEPPING_B0; @@ -1321,7 +1321,7 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i isp->hpll_freq = HPLL_FREQ_1600MHZ; break; case ATOMISP_PCI_DEVICE_SOC_CHT: - isp->media_dev.hw_revision = ( ATOMISP_HW_REVISION_ISP2401 + isp->media_dev.hw_revision = (ATOMISP_HW_REVISION_ISP2401 << ATOMISP_HW_REVISION_SHIFT); isp->media_dev.hw_revision |= pdev->revision < 2 ? ATOMISP_HW_STEPPING_A0 : ATOMISP_HW_STEPPING_B0; -- cgit v1.2.3 From 5b43a667775e600fb8a65667e252c31aa034f76d Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Tue, 26 Mar 2024 19:09:03 +0000 Subject: media: atomisp: Remove unsused macros Entire defs.h can be killed, so do that. Also kill same macro definitions in hive_types.h Link: https://lore.kernel.org/r/20240326190903.1422069-1-andriy.shevchenko@linux.intel.com Signed-off-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/bits.h | 4 +-- drivers/staging/media/atomisp/pci/defs.h | 37 ---------------------- .../pci/hive_isp_css_common/host/dma_local.h | 1 - drivers/staging/media/atomisp/pci/hive_types.h | 19 ----------- .../atomisp/pci/runtime/debug/src/ia_css_debug.c | 3 +- 5 files changed, 4 insertions(+), 60 deletions(-) delete mode 100644 drivers/staging/media/atomisp/pci/defs.h (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/bits.h b/drivers/staging/media/atomisp/pci/bits.h index 9fab02ebddc5..f7a66287d763 100644 --- a/drivers/staging/media/atomisp/pci/bits.h +++ b/drivers/staging/media/atomisp/pci/bits.h @@ -16,9 +16,9 @@ #ifndef _HRT_BITS_H #define _HRT_BITS_H -#include "defs.h" +#include -#define _hrt_ones(n) HRTCAT(_hrt_ones_, n) +#define _hrt_ones(n) CONCATENATE(_hrt_ones_, n) #define _hrt_ones_0x0 0x00000000U #define _hrt_ones_0x1 0x00000001U #define _hrt_ones_0x2 0x00000003U diff --git a/drivers/staging/media/atomisp/pci/defs.h b/drivers/staging/media/atomisp/pci/defs.h deleted file mode 100644 index 785e7a670a00..000000000000 --- a/drivers/staging/media/atomisp/pci/defs.h +++ /dev/null @@ -1,37 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Support for Intel Camera Imaging ISP subsystem. - * Copyright (c) 2015, Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - */ - -#ifndef _HRT_DEFS_H_ -#define _HRT_DEFS_H_ - -#ifndef HRTCAT -#define _HRTCAT(m, n) m##n -#define HRTCAT(m, n) _HRTCAT(m, n) -#endif - -#ifndef HRTSTR -#define _HRTSTR(x) #x -#define HRTSTR(x) _HRTSTR(x) -#endif - -#ifndef HRTMIN -#define HRTMIN(a, b) (((a) < (b)) ? (a) : (b)) -#endif - -#ifndef HRTMAX -#define HRTMAX(a, b) (((a) > (b)) ? (a) : (b)) -#endif - -#endif /* _HRT_DEFS_H_ */ diff --git a/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/dma_local.h b/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/dma_local.h index 48a1ace79897..1a71dbebbbe2 100644 --- a/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/dma_local.h +++ b/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/dma_local.h @@ -19,7 +19,6 @@ #include #include "dma_global.h" -#include /* HRTCAT() */ #include /* _hrt_get_bits() */ #include /* HIVE_DMA_NUM_CHANNELS */ #include diff --git a/drivers/staging/media/atomisp/pci/hive_types.h b/drivers/staging/media/atomisp/pci/hive_types.h index 55d36931f079..34f462c0c9f9 100644 --- a/drivers/staging/media/atomisp/pci/hive_types.h +++ b/drivers/staging/media/atomisp/pci/hive_types.h @@ -17,25 +17,6 @@ #define _HRT_HIVE_TYPES_H #include "version.h" -#include "defs.h" - -#ifndef HRTCAT3 -#define _HRTCAT3(m, n, o) m##n##o -#define HRTCAT3(m, n, o) _HRTCAT3(m, n, o) -#endif - -#ifndef HRTCAT4 -#define _HRTCAT4(m, n, o, p) m##n##o##p -#define HRTCAT4(m, n, o, p) _HRTCAT4(m, n, o, p) -#endif - -#ifndef HRTMIN -#define HRTMIN(a, b) (((a) < (b)) ? (a) : (b)) -#endif - -#ifndef HRTMAX -#define HRTMAX(a, b) (((a) > (b)) ? (a) : (b)) -#endif /* boolean data type */ typedef unsigned int hive_bool; diff --git a/drivers/staging/media/atomisp/pci/runtime/debug/src/ia_css_debug.c b/drivers/staging/media/atomisp/pci/runtime/debug/src/ia_css_debug.c index 3e92794555ec..3807b31bb98f 100644 --- a/drivers/staging/media/atomisp/pci/runtime/debug/src/ia_css_debug.c +++ b/drivers/staging/media/atomisp/pci/runtime/debug/src/ia_css_debug.c @@ -31,6 +31,7 @@ #define __INLINE_STREAM2MMIO__ #endif +#include #include /* for strscpy() */ #include "ia_css_debug.h" @@ -861,7 +862,7 @@ void ia_css_debug_wake_up_sp(void) } #define FIND_DMEM_PARAMS_TYPE(stream, kernel, type) \ - (struct HRTCAT(HRTCAT(sh_css_isp_, type), _params) *) \ + (struct CONCATENATE(CONCATENATE(sh_css_isp_, type), _params) *) \ findf_dmem_params(stream, offsetof(struct ia_css_memory_offsets, dmem.kernel)) #define FIND_DMEM_PARAMS(stream, kernel) FIND_DMEM_PARAMS_TYPE(stream, kernel, kernel) -- cgit v1.2.3 From c780a2c6ae629e1d380753b4df8cbf0bc72f375e Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Tue, 26 Mar 2024 20:27:02 +0000 Subject: media: atomisp: Put PMIC device after getting its I²C address MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don't use the PMIC I²C client device after getting its address. Drop the reference to it. We do not expect device to disappear as it should be taken care by the OpRegion drivers. Link: https://lore.kernel.org/r/20240326202813.1425431-2-andriy.shevchenko@linux.intel.com Signed-off-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c index 804ffff245f3..91c403128a4d 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c @@ -497,16 +497,19 @@ static u8 gmin_get_pmic_id_and_addr(struct device *dev) if (pmic_id) return pmic_i2c_addr; - if (gmin_i2c_dev_exists(dev, PMIC_ACPI_TI, &power)) + if (gmin_i2c_dev_exists(dev, PMIC_ACPI_TI, &power)) { pmic_id = PMIC_TI; - else if (gmin_i2c_dev_exists(dev, PMIC_ACPI_AXP, &power)) + } else if (gmin_i2c_dev_exists(dev, PMIC_ACPI_AXP, &power)) { pmic_id = PMIC_AXP; - else if (gmin_i2c_dev_exists(dev, PMIC_ACPI_CRYSTALCOVE, &power)) + } else if (gmin_i2c_dev_exists(dev, PMIC_ACPI_CRYSTALCOVE, &power)) { pmic_id = PMIC_CRYSTALCOVE; - else + } else { pmic_id = PMIC_REGULATOR; + return 0; + } - pmic_i2c_addr = power ? power->addr : 0; + pmic_i2c_addr = power->addr; + put_device(&power->dev); return pmic_i2c_addr; } -- cgit v1.2.3 From ca88632506f40033366ec65213676fffd0661632 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Wed, 10 Apr 2024 11:32:11 +0100 Subject: media: atomisp: Replace open-coded i2c_find_device_by_fwnode() gmin_i2c_dev_exists() is using open-coded variant of i2c_find_device_by_fwnode(). Replace it with a corresponding call. Link: https://lore.kernel.org/r/20240326202813.1425431-3-andriy.shevchenko@linux.intel.com Signed-off-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c index 91c403128a4d..a5e68b2cac50 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c @@ -388,20 +388,16 @@ static struct i2c_client *gmin_i2c_dev_exists(struct device *dev, char *name, struct i2c_client **client) { struct acpi_device *adev; - struct device *d; adev = acpi_dev_get_first_match_dev(name, NULL, -1); if (!adev) return NULL; - d = bus_find_device_by_acpi_dev(&i2c_bus_type, adev); + *client = i2c_find_device_by_fwnode(acpi_fwnode_handle(adev)); acpi_dev_put(adev); - if (!d) + if (!*client) return NULL; - *client = i2c_verify_client(d); - put_device(d); - dev_dbg(dev, "found '%s' at address 0x%02x, adapter %d\n", (*client)->name, (*client)->addr, (*client)->adapter->nr); return *client; -- cgit v1.2.3 From c7064fb60932227d6482d5300e06fc3673a4543d Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Tue, 2 Apr 2024 21:44:47 +0100 Subject: media: atomisp: Get rid of PCI device ID hack check Always check exact PCI ID match and drop hack checks. Link: https://lore.kernel.org/r/20240402204447.294280-1-andriy.shevchenko@linux.intel.com Signed-off-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- .../staging/media/atomisp/pci/atomisp_internal.h | 3 +- drivers/staging/media/atomisp/pci/atomisp_v4l2.c | 40 +++++++++++----------- 2 files changed, 21 insertions(+), 22 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_internal.h b/drivers/staging/media/atomisp/pci/atomisp_internal.h index ca8ed3a6b9b8..d6e86d013be9 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_internal.h +++ b/drivers/staging/media/atomisp/pci/atomisp_internal.h @@ -49,14 +49,13 @@ (((isp)->media_dev.hw_revision & ATOMISP_HW_REVISION_MASK) == \ ((rev) << ATOMISP_HW_REVISION_SHIFT)) -#define ATOMISP_PCI_DEVICE_SOC_MASK 0xfff8 +#define ATOMISP_PCI_DEVICE_SOC_BYT 0x0f38 /* MRFLD with 0x1178: ISP freq can burst to 457MHz */ #define ATOMISP_PCI_DEVICE_SOC_MRFLD 0x1178 /* MRFLD with 0x1179: max ISP freq limited to 400MHz */ #define ATOMISP_PCI_DEVICE_SOC_MRFLD_1179 0x1179 /* MRFLD with 0x117a: max ISP freq is 400MHz and max freq at Vmin is 200MHz */ #define ATOMISP_PCI_DEVICE_SOC_MRFLD_117A 0x117a -#define ATOMISP_PCI_DEVICE_SOC_BYT 0x0f38 #define ATOMISP_PCI_DEVICE_SOC_ANN 0x1478 #define ATOMISP_PCI_DEVICE_SOC_CHT 0x22b8 diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c index 7f702b151704..1d7d38e2f904 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c +++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c @@ -1226,7 +1226,8 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i const struct atomisp_platform_data *pdata; struct atomisp_device *isp; unsigned int start; - int err, val; + u32 val; + int err; /* Pointer to struct device. */ atomisp_dev = &pdev->dev; @@ -1254,8 +1255,10 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i pci_set_drvdata(pdev, isp); - switch (id->device & ATOMISP_PCI_DEVICE_SOC_MASK) { + switch (id->device) { case ATOMISP_PCI_DEVICE_SOC_MRFLD: + case ATOMISP_PCI_DEVICE_SOC_MRFLD_1179: + case ATOMISP_PCI_DEVICE_SOC_MRFLD_117A: isp->media_dev.hw_revision = (ATOMISP_HW_REVISION_ISP2400 << ATOMISP_HW_REVISION_SHIFT) | @@ -1408,28 +1411,25 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i */ atomisp_css2_hw_store_32(MRFLD_CSI_RECEIVER_SELECTION_REG, 1); - if ((id->device & ATOMISP_PCI_DEVICE_SOC_MASK) == - ATOMISP_PCI_DEVICE_SOC_MRFLD) { - u32 csi_afe_trim; - + switch (id->device) { + case ATOMISP_PCI_DEVICE_SOC_MRFLD: + case ATOMISP_PCI_DEVICE_SOC_MRFLD_1179: + case ATOMISP_PCI_DEVICE_SOC_MRFLD_117A: /* * Workaround for imbalance data eye issue which is observed * on TNG B0. */ - pci_read_config_dword(pdev, MRFLD_PCI_CSI_AFE_TRIM_CONTROL, &csi_afe_trim); - csi_afe_trim &= ~((MRFLD_PCI_CSI_HSRXCLKTRIM_MASK << - MRFLD_PCI_CSI1_HSRXCLKTRIM_SHIFT) | - (MRFLD_PCI_CSI_HSRXCLKTRIM_MASK << - MRFLD_PCI_CSI2_HSRXCLKTRIM_SHIFT) | - (MRFLD_PCI_CSI_HSRXCLKTRIM_MASK << - MRFLD_PCI_CSI3_HSRXCLKTRIM_SHIFT)); - csi_afe_trim |= (MRFLD_PCI_CSI1_HSRXCLKTRIM << - MRFLD_PCI_CSI1_HSRXCLKTRIM_SHIFT) | - (MRFLD_PCI_CSI2_HSRXCLKTRIM << - MRFLD_PCI_CSI2_HSRXCLKTRIM_SHIFT) | - (MRFLD_PCI_CSI3_HSRXCLKTRIM << - MRFLD_PCI_CSI3_HSRXCLKTRIM_SHIFT); - pci_write_config_dword(pdev, MRFLD_PCI_CSI_AFE_TRIM_CONTROL, csi_afe_trim); + pci_read_config_dword(pdev, MRFLD_PCI_CSI_AFE_TRIM_CONTROL, &val); + val &= ~((MRFLD_PCI_CSI_HSRXCLKTRIM_MASK << MRFLD_PCI_CSI1_HSRXCLKTRIM_SHIFT) | + (MRFLD_PCI_CSI_HSRXCLKTRIM_MASK << MRFLD_PCI_CSI2_HSRXCLKTRIM_SHIFT) | + (MRFLD_PCI_CSI_HSRXCLKTRIM_MASK << MRFLD_PCI_CSI3_HSRXCLKTRIM_SHIFT)); + val |= (MRFLD_PCI_CSI1_HSRXCLKTRIM << MRFLD_PCI_CSI1_HSRXCLKTRIM_SHIFT) | + (MRFLD_PCI_CSI2_HSRXCLKTRIM << MRFLD_PCI_CSI2_HSRXCLKTRIM_SHIFT) | + (MRFLD_PCI_CSI3_HSRXCLKTRIM << MRFLD_PCI_CSI3_HSRXCLKTRIM_SHIFT); + pci_write_config_dword(pdev, MRFLD_PCI_CSI_AFE_TRIM_CONTROL, val); + break; + default: + break; } err = atomisp_initialize_modules(isp); -- cgit v1.2.3 From 2eee9581745441080ad0bb4df0e159a44b686fc5 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Thu, 11 Apr 2024 18:42:16 +0100 Subject: media: atomisp: Add atomisp_s_sensor_power() helper Since the atomisp driver only supports 1 stream / only has 1 asd now, there is no longer a need to track which stream owns the sensor. So the asd owner-pointer of struct atomisp_input_subdev can be dropped, replace this with a simple camera_on boolean and add a new atomisp_s_sensor_power() helper which takes care of avoiding unbalanced s_power() subdev calls as well as takes care of handling the special -ENOIOCTLCMD return for subdevs which don't implement s_power(). Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_cmd.c | 17 +++++++++++++++++ drivers/staging/media/atomisp/pci/atomisp_cmd.h | 3 +++ drivers/staging/media/atomisp/pci/atomisp_fops.c | 14 +------------- .../staging/media/atomisp/pci/atomisp_internal.h | 6 +----- drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 21 ++++----------------- 5 files changed, 26 insertions(+), 35 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp_cmd.c index 3a56cf68b688..6b8ff9f1ae63 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c +++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c @@ -3722,6 +3722,23 @@ apply_min_padding: *padding_h = max_t(u32, *padding_h, min_pad_h); } +int atomisp_s_sensor_power(struct atomisp_device *isp, unsigned int input, bool on) +{ + int ret; + + if (isp->inputs[input].camera_on == on) + return 0; + + ret = v4l2_subdev_call(isp->inputs[input].camera, core, s_power, on); + if (ret && ret != -ENOIOCTLCMD) { + dev_err(isp->dev, "Error setting sensor power %d: %d\n", on, ret); + return ret; + } + + isp->inputs[input].camera_on = on; + return 0; +} + static int atomisp_set_sensor_crop_and_fmt(struct atomisp_device *isp, struct v4l2_mbus_framefmt *ffmt, int which) diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.h b/drivers/staging/media/atomisp/pci/atomisp_cmd.h index b8cd957eebdc..2676236ee015 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_cmd.h +++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.h @@ -241,6 +241,9 @@ int atomisp_compare_grid(struct atomisp_sub_device *asd, void atomisp_get_padding(struct atomisp_device *isp, u32 width, u32 height, u32 *padding_w, u32 *padding_h); +/* Set sensor power (no-op if already on/off) */ +int atomisp_s_sensor_power(struct atomisp_device *isp, unsigned int input, bool on); + /* This function looks up the closest available resolution. */ int atomisp_try_fmt(struct atomisp_device *isp, struct v4l2_pix_format *f, const struct atomisp_format_bridge **fmt_ret, diff --git a/drivers/staging/media/atomisp/pci/atomisp_fops.c b/drivers/staging/media/atomisp/pci/atomisp_fops.c index 4dba6120af39..b464a6bd0bad 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_fops.c +++ b/drivers/staging/media/atomisp/pci/atomisp_fops.c @@ -445,12 +445,8 @@ const struct vb2_ops atomisp_vb2_ops = { static void atomisp_dev_init_struct(struct atomisp_device *isp) { - unsigned int i; - isp->isp_fatal_error = false; - for (i = 0; i < isp->input_cnt; i++) - isp->inputs[i].asd = NULL; /* * For Merrifield, frequency is scalable. * After boot-up, the default frequency is 200MHz. @@ -584,15 +580,7 @@ static int atomisp_release(struct file *file) atomisp_css_free_stat_buffers(asd); atomisp_free_internal_buffers(asd); - if (isp->inputs[asd->input_curr].asd == asd) { - ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera, - core, s_power, 0); - if (ret && ret != -ENOIOCTLCMD) - dev_warn(isp->dev, "Failed to power-off sensor\n"); - - /* clear the asd field to show this camera is not used */ - isp->inputs[asd->input_curr].asd = NULL; - } + atomisp_s_sensor_power(isp, asd->input_curr, 0); atomisp_destroy_pipes_stream(asd); diff --git a/drivers/staging/media/atomisp/pci/atomisp_internal.h b/drivers/staging/media/atomisp/pci/atomisp_internal.h index d6e86d013be9..02fffa7f65e1 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_internal.h +++ b/drivers/staging/media/atomisp/pci/atomisp_internal.h @@ -127,17 +127,13 @@ struct atomisp_input_subdev { u32 code; /* MEDIA_BUS_FMT_* */ bool binning_support; bool crop_support; + bool camera_on; struct v4l2_subdev *camera; /* Sensor rects for sensors which support crop */ struct v4l2_rect native_rect; struct v4l2_rect active_rect; /* Sensor state for which == V4L2_SUBDEV_FORMAT_TRY calls */ struct v4l2_subdev_state *try_sd_state; - /* - * To show this resource is used by - * which stream, in ISP multiple stream mode - */ - struct atomisp_sub_device *asd; }; enum atomisp_dfs_mode { diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c index d602bda134f9..be1f3f2ee63e 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c +++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c @@ -469,28 +469,15 @@ static int atomisp_s_input(struct file *file, void *fh, unsigned int input) } /* power off the current owned sensor, as it is not used this time */ - if (isp->inputs[asd->input_curr].asd == asd && - asd->input_curr != input) { - ret = v4l2_subdev_call(isp->inputs[asd->input_curr].camera, - core, s_power, 0); - if (ret && ret != -ENOIOCTLCMD) - dev_warn(isp->dev, - "Failed to power-off sensor\n"); - /* clear the asd field to show this camera is not used */ - isp->inputs[asd->input_curr].asd = NULL; - } + if (input != isp->asd.input_curr) + atomisp_s_sensor_power(isp, isp->asd.input_curr, 0); /* powe on the new sensor */ - ret = v4l2_subdev_call(isp->inputs[input].camera, core, s_power, 1); - if (ret && ret != -ENOIOCTLCMD) { - dev_err(isp->dev, "Failed to power-on sensor\n"); + ret = atomisp_s_sensor_power(isp, input, 1); + if (ret) return ret; - } asd->input_curr = input; - /* mark this camera is used by the current stream */ - isp->inputs[input].asd = asd; - return 0; } -- cgit v1.2.3 From 61d9b1ffc68f109f987811e6d31d6440608f6e5c Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Thu, 11 Apr 2024 19:07:55 +0100 Subject: media: atomisp: Turn on sensor power from atomisp_set_fmt() ATM the atomisp driver does not call s_power() at all when no s_input ioctl() is done by the application. This breaks older sensor drivers which rely on s_power() for power-management. Some drivers have worked around this, e.g. commit c5fafbadaeae ("media: atomisp: gc0310: Power on sensor from set_fmt() callback") and commit b3118a942c82 ("media: atomisp: ov2722: Power on sensor from set_fmt() callback"), but this really should be fixed in the atomisp driver itself, so that all old drivers can work. A logical place to call s_power() would be from atomisp_start_streaming() / atomisp_stop_streaming(). But some older drivers, e.g. the atomisp-ov2722 driver already write mode related registers on set_fmt() instead of waiting on stream on. So the s_power(1) needs to happen at the first set_fmt(). Add an atomisp_s_sensor_power(..., 1) call just before calling set_fmt() for this. If the power was already enabled through e.g. a s_input ioctl atomisp_s_sensor_power() will skip calling the s_power() v4l2-subdev-op a second time. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_cmd.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp_cmd.c index 6b8ff9f1ae63..83a15a2d358e 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c +++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c @@ -3760,6 +3760,17 @@ static int atomisp_set_sensor_crop_and_fmt(struct atomisp_device *isp, if (!input->camera) return -EINVAL; + /* + * Some old sensor drivers already write the registers on set_fmt + * instead of on stream on, power on the sensor now (on newer + * sensor drivers the s_power op is a no-op). + */ + if (which == V4L2_SUBDEV_FORMAT_ACTIVE) { + ret = atomisp_s_sensor_power(isp, isp->asd.input_curr, 1); + if (ret) + return ret; + } + sd_state = (which == V4L2_SUBDEV_FORMAT_TRY) ? input->try_sd_state : input->camera->active_state; if (sd_state) -- cgit v1.2.3 From 1a1ce0c308136e2bfdf326e1100809fe34558a4e Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Thu, 11 Apr 2024 18:56:47 +0100 Subject: media: atomisp: Add atomisp_select_input() helper When switching input/sensor the s_power() callback must be called for old sensor drivers to power on the new sensor and power off the previous sensor. atomisp_s_input() already does this but atomisp_link_setup() did not do this. Add a new atomisp_select_input() helper which does this and use this in both atomisp_s_input() and atomisp_link_setup() for consistent behavior. Also make atomisp_link_setup() turn the sensor back off when a link gets disabled. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_cmd.c | 19 +++++++++++++++++++ drivers/staging/media/atomisp/pci/atomisp_cmd.h | 3 +++ drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 13 +------------ drivers/staging/media/atomisp/pci/atomisp_subdev.c | 15 +++++++++------ 4 files changed, 32 insertions(+), 18 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp_cmd.c index 83a15a2d358e..6c93bab17955 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c +++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c @@ -3739,6 +3739,25 @@ int atomisp_s_sensor_power(struct atomisp_device *isp, unsigned int input, bool return 0; } +int atomisp_select_input(struct atomisp_device *isp, unsigned int input) +{ + unsigned int input_orig = isp->asd.input_curr; + int ret; + + /* Power on new sensor */ + ret = atomisp_s_sensor_power(isp, input, 1); + if (ret) + return ret; + + isp->asd.input_curr = input; + + /* Power off previous sensor */ + if (input != input_orig) + atomisp_s_sensor_power(isp, input_orig, 0); + + return 0; +} + static int atomisp_set_sensor_crop_and_fmt(struct atomisp_device *isp, struct v4l2_mbus_framefmt *ffmt, int which) diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.h b/drivers/staging/media/atomisp/pci/atomisp_cmd.h index 2676236ee015..f302763b7b2f 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_cmd.h +++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.h @@ -244,6 +244,9 @@ void atomisp_get_padding(struct atomisp_device *isp, u32 width, u32 height, /* Set sensor power (no-op if already on/off) */ int atomisp_s_sensor_power(struct atomisp_device *isp, unsigned int input, bool on); +/* Select which sensor to use, must be called with a valid input */ +int atomisp_select_input(struct atomisp_device *isp, unsigned int input); + /* This function looks up the closest available resolution. */ int atomisp_try_fmt(struct atomisp_device *isp, struct v4l2_pix_format *f, const struct atomisp_format_bridge **fmt_ret, diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c index be1f3f2ee63e..b3ad53449cb8 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c +++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c @@ -449,7 +449,6 @@ static int atomisp_s_input(struct file *file, void *fh, unsigned int input) struct video_device *vdev = video_devdata(file); struct atomisp_device *isp = video_get_drvdata(vdev); struct atomisp_video_pipe *pipe = atomisp_to_video_pipe(vdev); - struct atomisp_sub_device *asd = pipe->asd; struct v4l2_subdev *camera = NULL; int ret; @@ -468,17 +467,7 @@ static int atomisp_s_input(struct file *file, void *fh, unsigned int input) return -EINVAL; } - /* power off the current owned sensor, as it is not used this time */ - if (input != isp->asd.input_curr) - atomisp_s_sensor_power(isp, isp->asd.input_curr, 0); - - /* powe on the new sensor */ - ret = atomisp_s_sensor_power(isp, input, 1); - if (ret) - return ret; - - asd->input_curr = input; - return 0; + return atomisp_select_input(isp, input); } /* diff --git a/drivers/staging/media/atomisp/pci/atomisp_subdev.c b/drivers/staging/media/atomisp/pci/atomisp_subdev.c index c36aae69d6f7..aabffd6a424d 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_subdev.c +++ b/drivers/staging/media/atomisp/pci/atomisp_subdev.c @@ -663,9 +663,6 @@ static int atomisp_link_setup(struct media_entity *entity, return -EINVAL; } - /* Ignore disables, input_curr should only be updated on enables */ - if (!(flags & MEDIA_LNK_FL_ENABLED)) - return 0; for (i = 0; i < isp->input_cnt; i++) { if (isp->inputs[i].camera == isp->sensor_subdevs[csi_idx]) @@ -679,11 +676,17 @@ static int atomisp_link_setup(struct media_entity *entity, mutex_lock(&isp->mutex); ret = atomisp_pipe_check(&asd->video_out, true); - if (ret == 0) - asd->input_curr = i; mutex_unlock(&isp->mutex); + if (ret) + return ret; - return ret; + /* Turn off the sensor on link disable */ + if (!(flags & MEDIA_LNK_FL_ENABLED)) { + atomisp_s_sensor_power(isp, i, 0); + return 0; + } + + return atomisp_select_input(isp, i); } static const struct media_entity_operations isp_subdev_media_ops = { -- cgit v1.2.3 From 2bcbeeb2979d6f97c150ed88488b16e2bf83bf64 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Thu, 11 Apr 2024 18:47:41 +0100 Subject: media: atomisp: Simplify atomisp_s_input() input argument checking Simplify the checking of the input argument to atomisp_s_input(): - Remove the check for input >= ATOM_ISP_MAX_INPUTS, input_cnt never is > ATOM_ISP_MAX_INPUTS so checking only that is sufficient - Remove the unnecessary camera local variable - Move the 2 invalid argument checks to above the atomisp_pipe_check() which checks if the pipe is busy or not Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c index b3ad53449cb8..1f8d44900a82 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c +++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c @@ -449,23 +449,17 @@ static int atomisp_s_input(struct file *file, void *fh, unsigned int input) struct video_device *vdev = video_devdata(file); struct atomisp_device *isp = video_get_drvdata(vdev); struct atomisp_video_pipe *pipe = atomisp_to_video_pipe(vdev); - struct v4l2_subdev *camera = NULL; int ret; - ret = atomisp_pipe_check(pipe, true); - if (ret) - return ret; - - if (input >= ATOM_ISP_MAX_INPUTS || input >= isp->input_cnt) { - dev_dbg(isp->dev, "input_cnt: %d\n", isp->input_cnt); + if (input >= isp->input_cnt) return -EINVAL; - } - camera = isp->inputs[input].camera; - if (!camera) { - dev_err(isp->dev, "%s, no camera\n", __func__); + if (!isp->inputs[input].camera) return -EINVAL; - } + + ret = atomisp_pipe_check(pipe, true); + if (ret) + return ret; return atomisp_select_input(isp, input); } -- cgit v1.2.3 From 2ab6c22d61e49518b6abd10105b747bc11780b95 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Thu, 11 Apr 2024 21:21:37 +0100 Subject: media: atomisp: Ensure CSI-receiver[x] -> ISP links correctly reflect current sensor Add a new atomisp_setup_input_links() helper which ensures that the CSI-receiver -> ISP link for input_curr is marked as enabled and the other CSI-receiver -> ISP links are disabled. And call this helper from atomisp_register_device_nodes() for the initial setup and from atomisp_select_input() for runtime input_curr changes. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_cmd.c | 34 +++++++++++++++++++++++ drivers/staging/media/atomisp/pci/atomisp_cmd.h | 3 ++ drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 6 +++- drivers/staging/media/atomisp/pci/atomisp_v4l2.c | 4 +++ 4 files changed, 46 insertions(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp_cmd.c index 6c93bab17955..b273234dc439 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c +++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c @@ -3755,9 +3755,43 @@ int atomisp_select_input(struct atomisp_device *isp, unsigned int input) if (input != input_orig) atomisp_s_sensor_power(isp, input_orig, 0); + atomisp_setup_input_links(isp); return 0; } +/* + * Ensure the CSI-receiver -> ISP link for input_curr is marked as enabled and + * the other CSI-receiver -> ISP links are disabled. + */ +void atomisp_setup_input_links(struct atomisp_device *isp) +{ + struct media_link *link; + + lockdep_assert_held(&isp->media_dev.graph_mutex); + + for (int i = 0; i < ATOMISP_CAMERA_NR_PORTS; i++) { + link = media_entity_find_link( + &isp->csi2_port[i].subdev.entity.pads[CSI2_PAD_SOURCE], + &isp->asd.subdev.entity.pads[ATOMISP_SUBDEV_PAD_SINK]); + if (!link) { + dev_err(isp->dev, "Error cannot find CSI2-port[%d] -> ISP link\n", i); + continue; /* Should never happen */ + } + + /* + * Modify the flags directly, calling media_entity_setup_link() + * will end up calling atomisp_link_setup() which calls this + * function again leading to endless recursion. + */ + if (isp->sensor_subdevs[i] == isp->inputs[isp->asd.input_curr].camera) + link->flags |= MEDIA_LNK_FL_ENABLED; + else + link->flags &= ~MEDIA_LNK_FL_ENABLED; + + link->reverse->flags = link->flags; + } +} + static int atomisp_set_sensor_crop_and_fmt(struct atomisp_device *isp, struct v4l2_mbus_framefmt *ffmt, int which) diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.h b/drivers/staging/media/atomisp/pci/atomisp_cmd.h index f302763b7b2f..03703eed86fa 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_cmd.h +++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.h @@ -247,6 +247,9 @@ int atomisp_s_sensor_power(struct atomisp_device *isp, unsigned int input, bool /* Select which sensor to use, must be called with a valid input */ int atomisp_select_input(struct atomisp_device *isp, unsigned int input); +/* Setup media-controller links to reflect input_curr setting */ +void atomisp_setup_input_links(struct atomisp_device *isp); + /* This function looks up the closest available resolution. */ int atomisp_try_fmt(struct atomisp_device *isp, struct v4l2_pix_format *f, const struct atomisp_format_bridge **fmt_ret, diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c index 1f8d44900a82..c16942051cfb 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c +++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c @@ -461,7 +461,11 @@ static int atomisp_s_input(struct file *file, void *fh, unsigned int input) if (ret) return ret; - return atomisp_select_input(isp, input); + mutex_lock(&isp->media_dev.graph_mutex); + ret = atomisp_select_input(isp, input); + mutex_unlock(&isp->media_dev.graph_mutex); + + return ret; } /* diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c index 1d7d38e2f904..1008a709b589 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c +++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c @@ -1085,6 +1085,10 @@ int atomisp_register_device_nodes(struct atomisp_device *isp) dev_warn(isp->dev, "too many atomisp inputs, TPG ignored.\n"); } + mutex_lock(&isp->media_dev.graph_mutex); + atomisp_setup_input_links(isp); + mutex_unlock(&isp->media_dev.graph_mutex); + isp->asd.video_out.vdev.v4l2_dev = &isp->v4l2_dev; isp->asd.video_out.vdev.device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; err = video_register_device(&isp->asd.video_out.vdev, VFL_TYPE_VIDEO, -1); -- cgit v1.2.3 From 52cc673b8d085255eacaebbf78525e2f33a9f95c Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Fri, 12 Apr 2024 14:51:15 +0100 Subject: media: atomisp: Propagate set_fmt on sensor results to CSI port So far the CSI port sink and source pads have not had their fmt set at all, leaving things at the default of SBGGR8_1X8/0x0. This means that pipeline validation such as e.g. done when calling media_pipeline_start() will fail since the links to / from the CSI ports have different fmts on each end. Store a pointer to the CSI port v4l2-subdev in struct atomisp_input_subdev, and use this in atomisp_set_sensor_crop_and_fmt() to propagate the sensors new fmt after a successful set_fmt to the CSI port it is connected too. The input->csi_port pointer also allows simplifying atomisp_link_setup(). Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_cmd.c | 7 +++++++ drivers/staging/media/atomisp/pci/atomisp_internal.h | 1 + drivers/staging/media/atomisp/pci/atomisp_subdev.c | 17 +++-------------- drivers/staging/media/atomisp/pci/atomisp_v4l2.c | 1 + 4 files changed, 12 insertions(+), 14 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp_cmd.c index b273234dc439..ecd521043021 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c +++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c @@ -3858,6 +3858,13 @@ set_fmt: if (sd_state) v4l2_subdev_unlock_state(sd_state); + /* Propagate new fmt to CSI port */ + if (which == V4L2_SUBDEV_FORMAT_ACTIVE) { + ret = v4l2_subdev_call(input->csi_port, pad, set_fmt, NULL, &format); + if (ret) + return ret; + } + *ffmt = format.format; return ret; } diff --git a/drivers/staging/media/atomisp/pci/atomisp_internal.h b/drivers/staging/media/atomisp/pci/atomisp_internal.h index 02fffa7f65e1..c81a1c5f2864 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_internal.h +++ b/drivers/staging/media/atomisp/pci/atomisp_internal.h @@ -129,6 +129,7 @@ struct atomisp_input_subdev { bool crop_support; bool camera_on; struct v4l2_subdev *camera; + struct v4l2_subdev *csi_port; /* Sensor rects for sensors which support crop */ struct v4l2_rect native_rect; struct v4l2_rect active_rect; diff --git a/drivers/staging/media/atomisp/pci/atomisp_subdev.c b/drivers/staging/media/atomisp/pci/atomisp_subdev.c index aabffd6a424d..53225958c23b 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_subdev.c +++ b/drivers/staging/media/atomisp/pci/atomisp_subdev.c @@ -644,7 +644,7 @@ static int atomisp_link_setup(struct media_entity *entity, entity); struct atomisp_sub_device *asd = v4l2_get_subdevdata(sd); struct atomisp_device *isp = asd->isp; - int i, csi_idx, ret; + int i, ret; /* ISP's source is immutable */ if (local != &asd->pads[ATOMISP_SUBDEV_PAD_SINK]) { @@ -653,24 +653,13 @@ static int atomisp_link_setup(struct media_entity *entity, return -EINVAL; } - for (csi_idx = 0; csi_idx < ATOMISP_CAMERA_NR_PORTS; csi_idx++) { - if (&isp->csi2_port[csi_idx].pads[CSI2_PAD_SOURCE] == remote) - break; - } - - if (csi_idx == ATOMISP_CAMERA_NR_PORTS) { - v4l2_err(sd, "Error cannot find CSI receiver for remote pad\n"); - return -EINVAL; - } - - for (i = 0; i < isp->input_cnt; i++) { - if (isp->inputs[i].camera == isp->sensor_subdevs[csi_idx]) + if (&isp->inputs[i].csi_port->entity.pads[CSI2_PAD_SOURCE] == remote) break; } if (i == isp->input_cnt) { - v4l2_err(sd, "Error no sensor for CSI receiver %d\n", csi_idx); + v4l2_err(sd, "Error no sensor for selected CSI receiver\n"); return -EINVAL; } diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c index 1008a709b589..809b9c4e7a92 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c +++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c @@ -1058,6 +1058,7 @@ int atomisp_register_device_nodes(struct atomisp_device *isp) input->type = RAW_CAMERA; input->port = i; input->camera = isp->sensor_subdevs[i]; + input->csi_port = &isp->csi2_port[i].subdev; atomisp_init_sensor(input); -- cgit v1.2.3 From 20a7f79982b5437bc8af44785326c59cf2f77378 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Fri, 12 Apr 2024 15:27:53 +0100 Subject: media: atomisp: Propagate v4l2_mbus_framefmt.field to CSI port sink pad Most sensor drivers report V4L2_FIELD_NONE as v4l2_mbus_framefmt.field value. Propagate this to the v4l2_mbus_framefmt for the CSI port to pass the link validation done by media_pipeline_start(). Keep the v4l2_mbus_framefmt.field for the source pad of the CSI port as V4L2_FIELD_ANY to match the ISP sink pad. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_csi2.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_csi2.c b/drivers/staging/media/atomisp/pci/atomisp_csi2.c index 89118438a3b6..e939a09a279b 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_csi2.c +++ b/drivers/staging/media/atomisp/pci/atomisp_csi2.c @@ -107,9 +107,12 @@ int atomisp_csi2_set_ffmt(struct v4l2_subdev *sd, actual_ffmt->height = clamp_t(u32, ffmt->height, ATOM_ISP_MIN_HEIGHT, ATOM_ISP_MAX_HEIGHT); + actual_ffmt->field = ffmt->field; tmp_ffmt = *ffmt = *actual_ffmt; + /* Always use V4L2_FIELD_ANY to match the ISP sink pad */ + tmp_ffmt.field = V4L2_FIELD_ANY; return atomisp_csi2_set_ffmt(sd, sd_state, which, CSI2_PAD_SOURCE, &tmp_ffmt); -- cgit v1.2.3 From 1c3432df2339c6fcc4399ea2299ad565bdb506e4 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Fri, 12 Apr 2024 13:39:50 +0100 Subject: media: atomisp: Call media_pipeline_alloc_start() in stream start Call media_pipeline_alloc_start() from atomisp_start_streaming() to mark all involved subdevs as busy so that the links cannot be changed through the media-controller APIs while streaming. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 15 +++++++++++++++ drivers/staging/media/atomisp/pci/atomisp_subdev.h | 1 + 2 files changed, 16 insertions(+) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c index c16942051cfb..8ef8cbc3b7a7 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c +++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c @@ -902,6 +902,20 @@ int atomisp_start_streaming(struct vb2_queue *vq, unsigned int count) if (ret) goto out_unlock; + /* + * When running a classic v4l2 app after a media-controller aware + * app, the CSI-receiver -> ISP link for the current sensor may be + * disabled. Fix this up before marking the pipeline as started. + */ + mutex_lock(&isp->media_dev.graph_mutex); + atomisp_setup_input_links(isp); + ret = __media_pipeline_start(&asd->video_out.vdev.entity.pads[0], &asd->video_out.pipe); + mutex_unlock(&isp->media_dev.graph_mutex); + if (ret) { + dev_err(isp->dev, "Error starting mc pipline: %d\n", ret); + goto out_unlock; + } + /* Input system HW workaround */ atomisp_dma_burst_len_cfg(asd); @@ -1054,6 +1068,7 @@ void atomisp_stop_streaming(struct vb2_queue *vq) if (ret) dev_warn(isp->dev, "Recreating streams failed: %d\n", ret); + media_pipeline_stop(&asd->video_out.vdev.entity.pads[0]); mutex_unlock(&isp->mutex); } diff --git a/drivers/staging/media/atomisp/pci/atomisp_subdev.h b/drivers/staging/media/atomisp/pci/atomisp_subdev.h index 9c1703bf439c..bcfa829dbf61 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_subdev.h +++ b/drivers/staging/media/atomisp/pci/atomisp_subdev.h @@ -49,6 +49,7 @@ struct atomisp_video_pipe { struct video_device vdev; enum v4l2_buf_type type; struct media_pad pad; + struct media_pipeline pipe; struct vb2_queue vb_queue; /* Lock for vb_queue, when also taking isp->mutex this must be taken first! */ struct mutex vb_queue_mutex; -- cgit v1.2.3 From e03a5d3e95f22d15d8dfd97b1d31ea6247931b48 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Wed, 10 Apr 2024 17:15:32 +0100 Subject: media: atomisp: Drop atomisp_pipe_check() from atomisp_link_setup() The media-controller core (__media_entity_setup_link()) already checks that the pads of the link are not streaming before calling the setup_link() pad-op so calling atomisp_pipe_check() is not necessary; and taking isp->mutex inside the setup_link() pad-op leads to a possible ABBA deadlock vs the media-device graph_mutex which in the case of the setup_link() pad-op is taken before calling the op, while in other scenarios the graph_mutex is taken after the isp->mutex. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_subdev.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_subdev.c b/drivers/staging/media/atomisp/pci/atomisp_subdev.c index 53225958c23b..1bb33460210c 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_subdev.c +++ b/drivers/staging/media/atomisp/pci/atomisp_subdev.c @@ -644,7 +644,7 @@ static int atomisp_link_setup(struct media_entity *entity, entity); struct atomisp_sub_device *asd = v4l2_get_subdevdata(sd); struct atomisp_device *isp = asd->isp; - int i, ret; + int i; /* ISP's source is immutable */ if (local != &asd->pads[ATOMISP_SUBDEV_PAD_SINK]) { @@ -663,12 +663,6 @@ static int atomisp_link_setup(struct media_entity *entity, return -EINVAL; } - mutex_lock(&isp->mutex); - ret = atomisp_pipe_check(&asd->video_out, true); - mutex_unlock(&isp->mutex); - if (ret) - return ret; - /* Turn off the sensor on link disable */ if (!(flags & MEDIA_LNK_FL_ENABLED)) { atomisp_s_sensor_power(isp, i, 0); -- cgit v1.2.3 From 36a1418540cea31789d87bcdbbe9f86ed309d039 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Fri, 12 Apr 2024 15:38:14 +0100 Subject: media: atomisp: ov2722: Remove power on sensor from set_fmt() callback The atomisp driver now properly ensures s_power(1) is called before calling the set_fmt() callback, so this workaround is no longer necessary. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/i2c/atomisp-ov2722.c | 12 ------------ drivers/staging/media/atomisp/i2c/ov2722.h | 1 - 2 files changed, 13 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/i2c/atomisp-ov2722.c b/drivers/staging/media/atomisp/i2c/atomisp-ov2722.c index 133e346ae51b..d60630ea16df 100644 --- a/drivers/staging/media/atomisp/i2c/atomisp-ov2722.c +++ b/drivers/staging/media/atomisp/i2c/atomisp-ov2722.c @@ -528,9 +528,6 @@ static int power_up(struct v4l2_subdev *sd) return -ENODEV; } - if (dev->power_on == 1) - return 0; /* Already on */ - /* power control */ ret = power_ctrl(sd, 1); if (ret) @@ -555,7 +552,6 @@ static int power_up(struct v4l2_subdev *sd) /* according to DS, 20ms is needed between PWDN and i2c access */ msleep(20); - dev->power_on = 1; return 0; fail_clk: @@ -579,9 +575,6 @@ static int power_down(struct v4l2_subdev *sd) return -ENODEV; } - if (dev->power_on == 0) - return 0; /* Already off */ - ret = dev->platform_data->flisclk_ctrl(sd, 0); if (ret) dev_err(&client->dev, "flisclk failed\n"); @@ -599,7 +592,6 @@ static int power_down(struct v4l2_subdev *sd) if (ret) dev_err(&client->dev, "vprog failed.\n"); - dev->power_on = 0; return ret; } @@ -677,9 +669,6 @@ static int ov2722_set_fmt(struct v4l2_subdev *sd, mutex_lock(&dev->input_lock); - /* s_power has not been called yet for std v4l2 clients (camorama) */ - power_up(sd); - dev->pixels_per_line = dev->res->pixels_per_line; dev->lines_per_frame = dev->res->lines_per_frame; @@ -978,7 +967,6 @@ static int ov2722_probe(struct i2c_client *client) return -ENOMEM; mutex_init(&dev->input_lock); - dev->power_on = -1; dev->res = &ov2722_res_preview[0]; v4l2_i2c_subdev_init(&dev->sd, client, &ov2722_ops); diff --git a/drivers/staging/media/atomisp/i2c/ov2722.h b/drivers/staging/media/atomisp/i2c/ov2722.h index 640d3ffcaa5c..5920a4d45d06 100644 --- a/drivers/staging/media/atomisp/i2c/ov2722.h +++ b/drivers/staging/media/atomisp/i2c/ov2722.h @@ -198,7 +198,6 @@ struct ov2722_device { struct ov2722_resolution *res; struct camera_sensor_platform_data *platform_data; - int power_on; u16 pixels_per_line; u16 lines_per_frame; u8 type; -- cgit v1.2.3 From a0821ca14bb808800e444e01f074e32dc4c0d161 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Fri, 12 Apr 2024 19:28:46 +0100 Subject: media: atomisp: Remove test pattern generator (TPG) support The TPG support registers a v4l2-subdev for this, but this is not part of the media-controller graph in any way. After manually selecting the TPG as input using the s_input ioctl it does not work. Several supported sensors have their own working TPG and using the sensor's TPG means that the same data-flow is used as with actual sensors rather then the quite different data-flow from the ISP's builtin TPG. Remove the broken TPG support, when a test-pattern is needed for testing a sensor's TPG can be used. Using a sensor's TPG is actually better for testing since then the actual normal data-flow is being tested. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/Makefile | 1 - .../media/atomisp/include/linux/atomisp_platform.h | 1 - drivers/staging/media/atomisp/pci/atomisp_cmd.c | 37 +++-- .../media/atomisp/pci/atomisp_compat_css20.c | 31 +--- .../staging/media/atomisp/pci/atomisp_internal.h | 2 - drivers/staging/media/atomisp/pci/atomisp_tpg.c | 164 --------------------- drivers/staging/media/atomisp/pci/atomisp_tpg.h | 39 ----- drivers/staging/media/atomisp/pci/atomisp_v4l2.c | 27 ---- .../pci/hive_isp_css_common/host/input_system.c | 38 ----- drivers/staging/media/atomisp/pci/ia_css.h | 1 - .../media/atomisp/pci/ia_css_stream_public.h | 3 - drivers/staging/media/atomisp/pci/ia_css_tpg.h | 79 ---------- .../atomisp/pci/isp2400_input_system_global.h | 1 - .../atomisp/pci/isp2400_input_system_public.h | 15 -- .../atomisp/pci/isp2401_input_system_global.h | 1 - .../atomisp/pci/runtime/debug/src/ia_css_debug.c | 17 --- .../media/atomisp/pci/runtime/ifmtr/src/ifmtr.c | 11 -- .../atomisp/pci/runtime/isys/src/virtual_isys.c | 28 +--- drivers/staging/media/atomisp/pci/sh_css.c | 88 +---------- .../staging/media/atomisp/pci/sh_css_internal.h | 1 - drivers/staging/media/atomisp/pci/sh_css_sp.c | 14 -- drivers/staging/media/atomisp/pci/sh_css_sp.h | 7 - 22 files changed, 21 insertions(+), 585 deletions(-) delete mode 100644 drivers/staging/media/atomisp/pci/atomisp_tpg.c delete mode 100644 drivers/staging/media/atomisp/pci/atomisp_tpg.h delete mode 100644 drivers/staging/media/atomisp/pci/ia_css_tpg.h (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/Makefile b/drivers/staging/media/atomisp/Makefile index fcd3e51ae9ce..43116c74781d 100644 --- a/drivers/staging/media/atomisp/Makefile +++ b/drivers/staging/media/atomisp/Makefile @@ -21,7 +21,6 @@ atomisp-objs += \ pci/atomisp_fops.o \ pci/atomisp_ioctl.o \ pci/atomisp_subdev.o \ - pci/atomisp_tpg.o \ pci/atomisp_v4l2.o \ pci/sh_css_firmware.o \ pci/sh_css_host_data.o \ diff --git a/drivers/staging/media/atomisp/include/linux/atomisp_platform.h b/drivers/staging/media/atomisp/include/linux/atomisp_platform.h index 2535402afd73..63dd7236e3a8 100644 --- a/drivers/staging/media/atomisp/include/linux/atomisp_platform.h +++ b/drivers/staging/media/atomisp/include/linux/atomisp_platform.h @@ -112,7 +112,6 @@ enum atomisp_input_format { enum intel_v4l2_subdev_type { RAW_CAMERA = 1, LED_FLASH = 2, - TEST_PATTERN = 3, }; struct intel_v4l2_subdev_id { diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp_cmd.c index ecd521043021..38b7ebb186a5 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c +++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c @@ -4133,6 +4133,7 @@ static int atomisp_set_fmt_to_isp(struct video_device *vdev, unsigned int width, unsigned int height) = configure_pp_input_nop; const struct atomisp_in_fmt_conv *fc = NULL; + struct v4l2_mbus_framefmt *ffmt; int ret, i; isp_sink_crop = atomisp_subdev_get_rect( @@ -4143,28 +4144,26 @@ static int atomisp_set_fmt_to_isp(struct video_device *vdev, if (!format) return -EINVAL; - if (input->type != TEST_PATTERN) { - mipi_info = atomisp_to_sensor_mipi_info(input->camera); + mipi_info = atomisp_to_sensor_mipi_info(input->camera); - if (atomisp_set_sensor_mipi_to_isp(asd, ATOMISP_INPUT_STREAM_GENERAL, - mipi_info)) - return -EINVAL; - - if (mipi_info) - fc = atomisp_find_in_fmt_conv_by_atomisp_in_fmt(mipi_info->input_format); + if (atomisp_set_sensor_mipi_to_isp(asd, ATOMISP_INPUT_STREAM_GENERAL, + mipi_info)) + return -EINVAL; - if (!fc) - fc = atomisp_find_in_fmt_conv( - atomisp_subdev_get_ffmt(&asd->subdev, - NULL, V4L2_SUBDEV_FORMAT_ACTIVE, - ATOMISP_SUBDEV_PAD_SINK)->code); - if (!fc) - return -EINVAL; - if (format->sh_fmt == IA_CSS_FRAME_FORMAT_RAW && - raw_output_format_match_input(fc->atomisp_in_fmt, - pix->pixelformat)) - return -EINVAL; + if (mipi_info) + fc = atomisp_find_in_fmt_conv_by_atomisp_in_fmt(mipi_info->input_format); + if (!fc) { + ffmt = atomisp_subdev_get_ffmt(&asd->subdev, NULL, + V4L2_SUBDEV_FORMAT_ACTIVE, + ATOMISP_SUBDEV_PAD_SINK); + fc = atomisp_find_in_fmt_conv(ffmt->code); } + if (!fc) + return -EINVAL; + + if (format->sh_fmt == IA_CSS_FRAME_FORMAT_RAW && + raw_output_format_match_input(fc->atomisp_in_fmt, pix->pixelformat)) + return -EINVAL; /* * Configure viewfinder also when vfpp is disabled: the diff --git a/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c b/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c index 6fe8b0b7467a..a62a5c0b3c00 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +++ b/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c @@ -302,21 +302,6 @@ static void __dump_stream_config(struct atomisp_sub_device *asd, "stream_config.source.port.compression.uncompressed_bits_per_pixel=%d.\n", s_config->source.port.compression. uncompressed_bits_per_pixel); - } else if (s_config->mode == IA_CSS_INPUT_MODE_TPG) { - dev_dbg(isp->dev, "stream_config.source.tpg.id=%d.\n", - s_config->source.tpg.id); - dev_dbg(isp->dev, "stream_config.source.tpg.mode=%d.\n", - s_config->source.tpg.mode); - dev_dbg(isp->dev, "stream_config.source.tpg.x_mask=%d.\n", - s_config->source.tpg.x_mask); - dev_dbg(isp->dev, "stream_config.source.tpg.x_delta=%d.\n", - s_config->source.tpg.x_delta); - dev_dbg(isp->dev, "stream_config.source.tpg.y_mask=%d.\n", - s_config->source.tpg.y_mask); - dev_dbg(isp->dev, "stream_config.source.tpg.y_delta=%d.\n", - s_config->source.tpg.y_delta); - dev_dbg(isp->dev, "stream_config.source.tpg.xy_mask=%d.\n", - s_config->source.tpg.xy_mask); } else if (s_config->mode == IA_CSS_INPUT_MODE_PRBS) { dev_dbg(isp->dev, "stream_config.source.prbs.id=%d.\n", s_config->source.prbs.id); @@ -1672,26 +1657,12 @@ void atomisp_css_capture_set_mode(struct atomisp_sub_device *asd, void atomisp_css_input_set_mode(struct atomisp_sub_device *asd, enum ia_css_input_mode mode) { - int i; - struct atomisp_device *isp = asd->isp; unsigned int size_mem_words; + int i; for (i = 0; i < ATOMISP_INPUT_STREAM_NUM; i++) asd->stream_env[i].stream_config.mode = mode; - if (isp->inputs[asd->input_curr].type == TEST_PATTERN) { - struct ia_css_stream_config *s_config = - &asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream_config; - s_config->mode = IA_CSS_INPUT_MODE_TPG; - s_config->source.tpg.mode = IA_CSS_TPG_MODE_CHECKERBOARD; - s_config->source.tpg.x_mask = (1 << 4) - 1; - s_config->source.tpg.x_delta = -2; - s_config->source.tpg.y_mask = (1 << 4) - 1; - s_config->source.tpg.y_delta = 3; - s_config->source.tpg.xy_mask = (1 << 8) - 1; - return; - } - if (mode != IA_CSS_INPUT_MODE_BUFFERED_SENSOR) return; diff --git a/drivers/staging/media/atomisp/pci/atomisp_internal.h b/drivers/staging/media/atomisp/pci/atomisp_internal.h index c81a1c5f2864..54ab872b91ee 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_internal.h +++ b/drivers/staging/media/atomisp/pci/atomisp_internal.h @@ -36,7 +36,6 @@ #include "atomisp_csi2.h" #include "atomisp_subdev.h" -#include "atomisp_tpg.h" #include "atomisp_compat.h" #include "gp_device.h" @@ -188,7 +187,6 @@ struct atomisp_device { bool pm_only; struct atomisp_mipi_csi2_device csi2_port[ATOMISP_CAMERA_NR_PORTS]; - struct atomisp_tpg_device tpg; /* Purpose of mutex is to protect and serialize use of isp data * structures and css API calls. */ diff --git a/drivers/staging/media/atomisp/pci/atomisp_tpg.c b/drivers/staging/media/atomisp/pci/atomisp_tpg.c deleted file mode 100644 index 92e61ee90993..000000000000 --- a/drivers/staging/media/atomisp/pci/atomisp_tpg.c +++ /dev/null @@ -1,164 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Support for Medifield PNW Camera Imaging ISP subsystem. - * - * Copyright (c) 2010 Intel Corporation. All Rights Reserved. - * - * Copyright (c) 2010 Silicon Hive www.siliconhive.com. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License version - * 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * - */ - -#include -#include -#include "atomisp_internal.h" -#include "atomisp_tpg.h" - -static int tpg_s_stream(struct v4l2_subdev *sd, int enable) -{ - return 0; -} - -static int tpg_get_fmt(struct v4l2_subdev *sd, - struct v4l2_subdev_state *sd_state, - struct v4l2_subdev_format *format) -{ - /*to fake*/ - return 0; -} - -static int tpg_set_fmt(struct v4l2_subdev *sd, - struct v4l2_subdev_state *sd_state, - struct v4l2_subdev_format *format) -{ - struct v4l2_mbus_framefmt *fmt = &format->format; - - if (format->pad) - return -EINVAL; - /* only raw8 grbg is supported by TPG */ - fmt->code = MEDIA_BUS_FMT_SGRBG8_1X8; - if (format->which == V4L2_SUBDEV_FORMAT_TRY) { - *v4l2_subdev_state_get_format(sd_state, 0) = *fmt; - return 0; - } - return 0; -} - -static int tpg_log_status(struct v4l2_subdev *sd) -{ - /*to fake*/ - return 0; -} - -static int tpg_s_power(struct v4l2_subdev *sd, int on) -{ - return 0; -} - -static int tpg_enum_mbus_code(struct v4l2_subdev *sd, - struct v4l2_subdev_state *sd_state, - struct v4l2_subdev_mbus_code_enum *code) -{ - /*to fake*/ - return 0; -} - -static int tpg_enum_frame_size(struct v4l2_subdev *sd, - struct v4l2_subdev_state *sd_state, - struct v4l2_subdev_frame_size_enum *fse) -{ - /*to fake*/ - return 0; -} - -static int tpg_enum_frame_ival(struct v4l2_subdev *sd, - struct v4l2_subdev_state *sd_state, - struct v4l2_subdev_frame_interval_enum *fie) -{ - /*to fake*/ - return 0; -} - -static const struct v4l2_subdev_video_ops tpg_video_ops = { - .s_stream = tpg_s_stream, -}; - -static const struct v4l2_subdev_core_ops tpg_core_ops = { - .log_status = tpg_log_status, - .s_power = tpg_s_power, -}; - -static const struct v4l2_subdev_pad_ops tpg_pad_ops = { - .enum_mbus_code = tpg_enum_mbus_code, - .enum_frame_size = tpg_enum_frame_size, - .enum_frame_interval = tpg_enum_frame_ival, - .get_fmt = tpg_get_fmt, - .set_fmt = tpg_set_fmt, -}; - -static const struct v4l2_subdev_ops tpg_ops = { - .core = &tpg_core_ops, - .video = &tpg_video_ops, - .pad = &tpg_pad_ops, -}; - -void atomisp_tpg_unregister_entities(struct atomisp_tpg_device *tpg) -{ - media_entity_cleanup(&tpg->sd.entity); - v4l2_device_unregister_subdev(&tpg->sd); -} - -int atomisp_tpg_register_entities(struct atomisp_tpg_device *tpg, - struct v4l2_device *vdev) -{ - int ret; - /* Register the subdev and video nodes. */ - ret = v4l2_device_register_subdev(vdev, &tpg->sd); - if (ret < 0) - goto error; - - return 0; - -error: - atomisp_tpg_unregister_entities(tpg); - return ret; -} - -void atomisp_tpg_cleanup(struct atomisp_device *isp) -{ -} - -int atomisp_tpg_init(struct atomisp_device *isp) -{ - struct atomisp_tpg_device *tpg = &isp->tpg; - struct v4l2_subdev *sd = &tpg->sd; - struct media_pad *pads = tpg->pads; - struct media_entity *me = &sd->entity; - int ret; - - tpg->isp = isp; - v4l2_subdev_init(sd, &tpg_ops); - sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; - strscpy(sd->name, "tpg_subdev", sizeof(sd->name)); - v4l2_set_subdevdata(sd, tpg); - - pads[0].flags = MEDIA_PAD_FL_SINK; - me->function = MEDIA_ENT_F_PROC_VIDEO_ISP; - - ret = media_entity_pads_init(me, 1, pads); - if (ret < 0) - goto fail; - return 0; -fail: - atomisp_tpg_cleanup(isp); - return ret; -} diff --git a/drivers/staging/media/atomisp/pci/atomisp_tpg.h b/drivers/staging/media/atomisp/pci/atomisp_tpg.h deleted file mode 100644 index 4176e076f63d..000000000000 --- a/drivers/staging/media/atomisp/pci/atomisp_tpg.h +++ /dev/null @@ -1,39 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Support for Medifield PNW Camera Imaging ISP subsystem. - * - * Copyright (c) 2010 Intel Corporation. All Rights Reserved. - * - * Copyright (c) 2010 Silicon Hive www.siliconhive.com. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License version - * 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * - */ - -#ifndef __ATOMISP_TPG_H__ -#define __ATOMISP_TPG_H__ - -#include -#include - -struct atomisp_tpg_device { - struct v4l2_subdev sd; - struct atomisp_device *isp; - struct media_pad pads[1]; -}; - -void atomisp_tpg_cleanup(struct atomisp_device *isp); -int atomisp_tpg_init(struct atomisp_device *isp); -void atomisp_tpg_unregister_entities(struct atomisp_tpg_device *tpg); -int atomisp_tpg_register_entities(struct atomisp_tpg_device *tpg, - struct v4l2_device *vdev); - -#endif /* __ATOMISP_TPG_H__ */ diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c index 809b9c4e7a92..0069b547754d 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c +++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c @@ -847,7 +847,6 @@ static void atomisp_unregister_entities(struct atomisp_device *isp) struct v4l2_subdev *sd, *next; atomisp_subdev_unregister_entities(&isp->asd); - atomisp_tpg_unregister_entities(&isp->tpg); for (i = 0; i < ATOMISP_CAMERA_NR_PORTS; i++) atomisp_mipi_csi2_unregister_entities(&isp->csi2_port[i]); @@ -902,12 +901,6 @@ static int atomisp_register_entities(struct atomisp_device *isp) goto csi_and_subdev_probe_failed; } - ret = atomisp_tpg_register_entities(&isp->tpg, &isp->v4l2_dev); - if (ret < 0) { - dev_err(isp->dev, "atomisp_tpg_register_entities\n"); - goto tpg_register_failed; - } - ret = atomisp_subdev_register_subdev(&isp->asd, &isp->v4l2_dev); if (ret < 0) { dev_err(isp->dev, "atomisp_subdev_register_subdev fail\n"); @@ -917,8 +910,6 @@ static int atomisp_register_entities(struct atomisp_device *isp) return 0; subdev_register_failed: - atomisp_tpg_unregister_entities(&isp->tpg); -tpg_register_failed: for (i = 0; i < ATOMISP_CAMERA_NR_PORTS; i++) atomisp_mipi_csi2_unregister_entities(&isp->csi2_port[i]); csi_and_subdev_probe_failed: @@ -1077,15 +1068,6 @@ int atomisp_register_device_nodes(struct atomisp_device *isp) else dev_info(isp->dev, "detected %d camera sensors\n", isp->input_cnt); - if (isp->input_cnt < ATOM_ISP_MAX_INPUTS) { - dev_dbg(isp->dev, "TPG detected, camera_cnt: %d\n", isp->input_cnt); - isp->inputs[isp->input_cnt].type = TEST_PATTERN; - isp->inputs[isp->input_cnt].port = -1; - isp->inputs[isp->input_cnt++].camera = &isp->tpg.sd; - } else { - dev_warn(isp->dev, "too many atomisp inputs, TPG ignored.\n"); - } - mutex_lock(&isp->media_dev.graph_mutex); atomisp_setup_input_links(isp); mutex_unlock(&isp->media_dev.graph_mutex); @@ -1119,12 +1101,6 @@ static int atomisp_initialize_modules(struct atomisp_device *isp) goto error_mipi_csi2; } - ret = atomisp_tpg_init(isp); - if (ret < 0) { - dev_err(isp->dev, "tpg initialization failed\n"); - goto error_tpg; - } - ret = atomisp_subdev_init(isp); if (ret < 0) { dev_err(isp->dev, "ISP subdev initialization failed\n"); @@ -1134,8 +1110,6 @@ static int atomisp_initialize_modules(struct atomisp_device *isp) return 0; error_isp_subdev: -error_tpg: - atomisp_tpg_cleanup(isp); error_mipi_csi2: atomisp_mipi_csi2_cleanup(isp); return ret; @@ -1143,7 +1117,6 @@ error_mipi_csi2: static void atomisp_uninitialize_modules(struct atomisp_device *isp) { - atomisp_tpg_cleanup(isp); atomisp_mipi_csi2_cleanup(isp); } diff --git a/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/input_system.c b/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/input_system.c index ca1ce6689034..8f2f4e8eddd9 100644 --- a/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/input_system.c +++ b/drivers/staging/media/atomisp/pci/hive_isp_css_common/host/input_system.c @@ -426,7 +426,6 @@ static input_system_err_t input_system_configure_channel( case INPUT_SYSTEM_SOURCE_SENSOR: error = input_system_configure_channel_sensor(channel); break; - case INPUT_SYSTEM_SOURCE_TPG: case INPUT_SYSTEM_SOURCE_PRBS: case INPUT_SYSTEM_SOURCE_FIFO: default: @@ -814,7 +813,6 @@ static input_system_err_t configuration_to_registers(void) //... break; - case INPUT_SYSTEM_SOURCE_TPG: case INPUT_SYSTEM_SOURCE_PRBS: case INPUT_SYSTEM_SOURCE_FIFO: break; @@ -1065,42 +1063,6 @@ input_system_err_t input_system_prbs_channel_cfg( return input_system_configure_channel(channel); } -input_system_err_t input_system_tpg_channel_cfg( - u32 ch_id, - u32 nof_frames,//not used yet - u32 x_mask, - u32 y_mask, - u32 x_delta, - u32 y_delta, - u32 xy_mask, - u32 sync_gen_width, - u32 sync_gen_height, - u32 sync_gen_hblank_cycles, - u32 sync_gen_vblank_cycles, - target_cfg2400_t target -) -{ - channel_cfg_t channel; - - (void)nof_frames; - - channel.ch_id = ch_id; - channel.source_type = INPUT_SYSTEM_SOURCE_TPG; - - channel.source_cfg.tpg_cfg.x_mask = x_mask; - channel.source_cfg.tpg_cfg.y_mask = y_mask; - channel.source_cfg.tpg_cfg.x_delta = x_delta; - channel.source_cfg.tpg_cfg.y_delta = y_delta; - channel.source_cfg.tpg_cfg.xy_mask = xy_mask; - channel.source_cfg.tpg_cfg.sync_gen_cfg.width = sync_gen_width; - channel.source_cfg.tpg_cfg.sync_gen_cfg.height = sync_gen_height; - channel.source_cfg.tpg_cfg.sync_gen_cfg.hblank_cycles = sync_gen_hblank_cycles; - channel.source_cfg.tpg_cfg.sync_gen_cfg.vblank_cycles = sync_gen_vblank_cycles; - - channel.target_cfg = target; - return input_system_configure_channel(channel); -} - // MW: Don't use system specific names, (even in system specific files) "cfg2400" -> cfg input_system_err_t input_system_gpfifo_channel_cfg( u32 ch_id, diff --git a/drivers/staging/media/atomisp/pci/ia_css.h b/drivers/staging/media/atomisp/pci/ia_css.h index d83e1ae5b0b3..421056287853 100644 --- a/drivers/staging/media/atomisp/pci/ia_css.h +++ b/drivers/staging/media/atomisp/pci/ia_css.h @@ -42,7 +42,6 @@ #include "ia_css_properties.h" #include "ia_css_stream_format.h" #include "ia_css_stream_public.h" -#include "ia_css_tpg.h" #include "ia_css_version.h" #include "ia_css_mmu.h" #include "ia_css_morph.h" diff --git a/drivers/staging/media/atomisp/pci/ia_css_stream_public.h b/drivers/staging/media/atomisp/pci/ia_css_stream_public.h index 47846ece8d64..888f54d8495e 100644 --- a/drivers/staging/media/atomisp/pci/ia_css_stream_public.h +++ b/drivers/staging/media/atomisp/pci/ia_css_stream_public.h @@ -24,7 +24,6 @@ #include "ia_css_types.h" #include "ia_css_pipe_public.h" #include "ia_css_metadata.h" -#include "ia_css_tpg.h" #include "ia_css_prbs.h" #include "ia_css_input_port.h" @@ -34,7 +33,6 @@ enum ia_css_input_mode { IA_CSS_INPUT_MODE_SENSOR, /** data from sensor */ IA_CSS_INPUT_MODE_FIFO, /** data from input-fifo */ - IA_CSS_INPUT_MODE_TPG, /** data from test-pattern generator */ IA_CSS_INPUT_MODE_PRBS, /** data from pseudo-random bit stream */ IA_CSS_INPUT_MODE_MEMORY, /** data from a frame in memory */ IA_CSS_INPUT_MODE_BUFFERED_SENSOR /** data is sent through mipi buffer */ @@ -91,7 +89,6 @@ struct ia_css_stream_config { enum ia_css_input_mode mode; /** Input mode */ union { struct ia_css_input_port port; /** Port, for sensor only. */ - struct ia_css_tpg_config tpg; /** TPG configuration */ struct ia_css_prbs_config prbs; /** PRBS configuration */ } source; /** Source of input data */ unsigned int channel_id; /** Channel on which input data diff --git a/drivers/staging/media/atomisp/pci/ia_css_tpg.h b/drivers/staging/media/atomisp/pci/ia_css_tpg.h deleted file mode 100644 index 8c744bedb0a6..000000000000 --- a/drivers/staging/media/atomisp/pci/ia_css_tpg.h +++ /dev/null @@ -1,79 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Support for Intel Camera Imaging ISP subsystem. - * Copyright (c) 2015, Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - */ - -#ifndef __IA_CSS_TPG_H -#define __IA_CSS_TPG_H - -/* @file - * This file contains support for the test pattern generator (TPG) - */ - -/* Enumerate the TPG IDs. - */ -enum ia_css_tpg_id { - IA_CSS_TPG_ID0, - IA_CSS_TPG_ID1, - IA_CSS_TPG_ID2 -}; - -/** - * Maximum number of TPG IDs. - * - * Make sure the value of this define gets changed to reflect the correct - * number of ia_css_tpg_id enum if you add/delete an item in the enum. - */ -#define N_CSS_TPG_IDS (IA_CSS_TPG_ID2 + 1) - -/* Enumerate the TPG modes. - */ -enum ia_css_tpg_mode { - IA_CSS_TPG_MODE_RAMP, - IA_CSS_TPG_MODE_CHECKERBOARD, - IA_CSS_TPG_MODE_FRAME_BASED_COLOR, - IA_CSS_TPG_MODE_MONO -}; - -/* @brief Configure the test pattern generator. - * - * Configure the Test Pattern Generator, the way these values are used to - * generate the pattern can be seen in the HRT extension for the test pattern - * generator: - * devices/test_pat_gen/hrt/include/test_pat_gen.h: hrt_calc_tpg_data(). - * - * This interface is deprecated, it is not portable -> move to input system API - * -@code -unsigned int test_pattern_value(unsigned int x, unsigned int y) -{ - unsigned int x_val, y_val; - if (x_delta > 0) (x_val = (x << x_delta) & x_mask; - else (x_val = (x >> -x_delta) & x_mask; - if (y_delta > 0) (y_val = (y << y_delta) & y_mask; - else (y_val = (y >> -y_delta) & x_mask; - return (x_val + y_val) & xy_mask; -} -@endcode - */ -struct ia_css_tpg_config { - enum ia_css_tpg_id id; - enum ia_css_tpg_mode mode; - unsigned int x_mask; - int x_delta; - unsigned int y_mask; - int y_delta; - unsigned int xy_mask; -}; - -#endif /* __IA_CSS_TPG_H */ diff --git a/drivers/staging/media/atomisp/pci/isp2400_input_system_global.h b/drivers/staging/media/atomisp/pci/isp2400_input_system_global.h index 3ff61faf0621..c00acf764b93 100644 --- a/drivers/staging/media/atomisp/pci/isp2400_input_system_global.h +++ b/drivers/staging/media/atomisp/pci/isp2400_input_system_global.h @@ -35,7 +35,6 @@ typedef enum { typedef enum { INPUT_SYSTEM_SOURCE_SENSOR = 0, INPUT_SYSTEM_SOURCE_FIFO, - INPUT_SYSTEM_SOURCE_TPG, INPUT_SYSTEM_SOURCE_PRBS, INPUT_SYSTEM_SOURCE_MEMORY, N_INPUT_SYSTEM_SOURCE diff --git a/drivers/staging/media/atomisp/pci/isp2400_input_system_public.h b/drivers/staging/media/atomisp/pci/isp2400_input_system_public.h index 523c948923f3..03b7ab7a70d9 100644 --- a/drivers/staging/media/atomisp/pci/isp2400_input_system_public.h +++ b/drivers/staging/media/atomisp/pci/isp2400_input_system_public.h @@ -308,21 +308,6 @@ input_system_err_t input_system_prbs_channel_cfg( target_cfg2400_t target ); -input_system_err_t input_system_tpg_channel_cfg( - u32 ch_id, - u32 nof_frames,//not used yet - u32 x_mask, - u32 y_mask, - u32 x_delta, - u32 y_delta, - u32 xy_mask, - u32 sync_gen_width, - u32 sync_gen_height, - u32 sync_gen_hblank_cycles, - u32 sync_gen_vblank_cycles, - target_cfg2400_t target -); - input_system_err_t input_system_gpfifo_channel_cfg( u32 ch_id, u32 nof_frames, diff --git a/drivers/staging/media/atomisp/pci/isp2401_input_system_global.h b/drivers/staging/media/atomisp/pci/isp2401_input_system_global.h index e3c86069b390..b116be415074 100644 --- a/drivers/staging/media/atomisp/pci/isp2401_input_system_global.h +++ b/drivers/staging/media/atomisp/pci/isp2401_input_system_global.h @@ -39,7 +39,6 @@ typedef enum { INPUT_SYSTEM_SOURCE_TYPE_UNDEFINED = 0, INPUT_SYSTEM_SOURCE_TYPE_SENSOR, - INPUT_SYSTEM_SOURCE_TYPE_TPG, INPUT_SYSTEM_SOURCE_TYPE_PRBS, N_INPUT_SYSTEM_SOURCE_TYPE } input_system_source_type_t; diff --git a/drivers/staging/media/atomisp/pci/runtime/debug/src/ia_css_debug.c b/drivers/staging/media/atomisp/pci/runtime/debug/src/ia_css_debug.c index 3807b31bb98f..9982e77716a7 100644 --- a/drivers/staging/media/atomisp/pci/runtime/debug/src/ia_css_debug.c +++ b/drivers/staging/media/atomisp/pci/runtime/debug/src/ia_css_debug.c @@ -1549,23 +1549,6 @@ ia_css_debug_dump_stream_config_source( ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "compression: %d\n", config->source.port.compression.type); break; - case IA_CSS_INPUT_MODE_TPG: - ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "source.tpg\n"); - ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "id: %d\n", - config->source.tpg.id); - ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "mode: %d\n", - config->source.tpg.mode); - ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "x_mask: 0x%x\n", - config->source.tpg.x_mask); - ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "x_delta: %d\n", - config->source.tpg.x_delta); - ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "y_mask: 0x%x\n", - config->source.tpg.y_mask); - ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "y_delta: %d\n", - config->source.tpg.y_delta); - ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "xy_mask: 0x%x\n", - config->source.tpg.xy_mask); - break; case IA_CSS_INPUT_MODE_PRBS: ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "source.prbs\n"); ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "id: %d\n", diff --git a/drivers/staging/media/atomisp/pci/runtime/ifmtr/src/ifmtr.c b/drivers/staging/media/atomisp/pci/runtime/ifmtr/src/ifmtr.c index 86254888f676..7b5603e4e173 100644 --- a/drivers/staging/media/atomisp/pci/runtime/ifmtr/src/ifmtr.c +++ b/drivers/staging/media/atomisp/pci/runtime/ifmtr/src/ifmtr.c @@ -382,17 +382,6 @@ int ia_css_ifmtr_configure(struct ia_css_stream_config *config, vectors_per_buffer = buffer_height * buffer_width / ISP_VEC_NELEMS; - if (config->mode == IA_CSS_INPUT_MODE_TPG && - ((binary && binary->info->sp.pipeline.mode == IA_CSS_BINARY_MODE_VIDEO) || - (!binary))) { - /* !binary -> sp raw copy pipe */ - /* workaround for TPG in video mode */ - start_line = 0; - start_column = 0; - cropped_height -= start_line; - width_a -= start_column; - } - if_a_config.start_line = start_line; if_a_config.start_column = start_column; if_a_config.left_padding = left_padding / deinterleaving; diff --git a/drivers/staging/media/atomisp/pci/runtime/isys/src/virtual_isys.c b/drivers/staging/media/atomisp/pci/runtime/isys/src/virtual_isys.c index 269a81190577..52483498239d 100644 --- a/drivers/staging/media/atomisp/pci/runtime/isys/src/virtual_isys.c +++ b/drivers/staging/media/atomisp/pci/runtime/isys/src/virtual_isys.c @@ -96,12 +96,6 @@ static void release_be_lut_entry( csi_mipi_packet_type_t packet_type, csi_rx_backend_lut_entry_t *entry); -static bool calculate_tpg_cfg( - input_system_channel_t *channel, - input_system_input_port_t *input_port, - isp2401_input_system_cfg_t *isys_cfg, - pixelgen_tpg_cfg_t *cfg); - static bool calculate_prbs_cfg( input_system_channel_t *channel, input_system_input_port_t *input_port, @@ -517,13 +511,6 @@ static bool calculate_input_system_input_port_cfg( rc &= calculate_be_cfg(input_port, isys_cfg, true, &input_port_cfg->csi_rx_cfg.md_backend_cfg); break; - case INPUT_SYSTEM_SOURCE_TYPE_TPG: - rc = calculate_tpg_cfg( - channel, - input_port, - isys_cfg, - &input_port_cfg->pixelgen_cfg.tpg_cfg); - break; case INPUT_SYSTEM_SOURCE_TYPE_PRBS: rc = calculate_prbs_cfg( channel, @@ -633,17 +620,6 @@ static void release_be_lut_entry( ia_css_isys_csi_rx_lut_rmgr_release(backend, packet_type, entry); } -static bool calculate_tpg_cfg( - input_system_channel_t *channel, - input_system_input_port_t *input_port, - isp2401_input_system_cfg_t *isys_cfg, - pixelgen_tpg_cfg_t *cfg) -{ - memcpy(cfg, &isys_cfg->tpg_port_attr, sizeof(pixelgen_tpg_cfg_t)); - - return true; -} - static bool calculate_prbs_cfg( input_system_channel_t *channel, input_system_input_port_t *input_port, @@ -703,9 +679,7 @@ static bool calculate_stream2mmio_cfg( cfg->bits_per_pixel = metadata ? isys_cfg->metadata.bits_per_pixel : isys_cfg->input_port_resolution.bits_per_pixel; - cfg->enable_blocking = - ((isys_cfg->mode == INPUT_SYSTEM_SOURCE_TYPE_TPG) || - (isys_cfg->mode == INPUT_SYSTEM_SOURCE_TYPE_PRBS)); + cfg->enable_blocking = isys_cfg->mode == INPUT_SYSTEM_SOURCE_TYPE_PRBS; return true; } diff --git a/drivers/staging/media/atomisp/pci/sh_css.c b/drivers/staging/media/atomisp/pci/sh_css.c index 8c30191b21a7..22c8cdcb2eb8 100644 --- a/drivers/staging/media/atomisp/pci/sh_css.c +++ b/drivers/staging/media/atomisp/pci/sh_css.c @@ -462,9 +462,6 @@ ia_css_stream_input_format_bits_per_pixel(struct ia_css_stream *stream) return bpp; } -/* TODO: move define to proper file in tools */ -#define GP_ISEL_TPG_MODE 0x90058 - static int sh_css_config_input_network_2400(struct ia_css_stream *stream) { @@ -500,8 +497,7 @@ sh_css_config_input_network_2400(struct ia_css_stream *stream) return err; } - if (stream->config.mode == IA_CSS_INPUT_MODE_TPG || - stream->config.mode == IA_CSS_INPUT_MODE_PRBS) { + if (stream->config.mode == IA_CSS_INPUT_MODE_PRBS) { unsigned int hblank_cycles = 100, vblank_lines = 6, width, @@ -513,8 +509,6 @@ sh_css_config_input_network_2400(struct ia_css_stream *stream) vblank_cycles = vblank_lines * (width + hblank_cycles); sh_css_sp_configure_sync_gen(width, height, hblank_cycles, vblank_cycles); - if (pipe->stream->config.mode == IA_CSS_INPUT_MODE_TPG) - ia_css_device_store_uint32(GP_ISEL_TPG_MODE, 0); } ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "sh_css_config_input_network() leave:\n"); @@ -654,16 +648,6 @@ static bool sh_css_translate_stream_cfg_to_input_system_input_port_id( rc = true; switch (stream_cfg->mode) { - case IA_CSS_INPUT_MODE_TPG: - - if (stream_cfg->source.tpg.id == IA_CSS_TPG_ID0) - isys_stream_descr->input_port_id = INPUT_SYSTEM_PIXELGEN_PORT0_ID; - else if (stream_cfg->source.tpg.id == IA_CSS_TPG_ID1) - isys_stream_descr->input_port_id = INPUT_SYSTEM_PIXELGEN_PORT1_ID; - else if (stream_cfg->source.tpg.id == IA_CSS_TPG_ID2) - isys_stream_descr->input_port_id = INPUT_SYSTEM_PIXELGEN_PORT2_ID; - - break; case IA_CSS_INPUT_MODE_PRBS: if (stream_cfg->source.prbs.id == IA_CSS_PRBS_ID0) @@ -700,11 +684,6 @@ static bool sh_css_translate_stream_cfg_to_input_system_input_port_type( rc = true; switch (stream_cfg->mode) { - case IA_CSS_INPUT_MODE_TPG: - - isys_stream_descr->mode = INPUT_SYSTEM_SOURCE_TYPE_TPG; - - break; case IA_CSS_INPUT_MODE_PRBS: isys_stream_descr->mode = INPUT_SYSTEM_SOURCE_TYPE_PRBS; @@ -733,54 +712,6 @@ static bool sh_css_translate_stream_cfg_to_input_system_input_port_attr( rc = true; switch (stream_cfg->mode) { - case IA_CSS_INPUT_MODE_TPG: - if (stream_cfg->source.tpg.mode == IA_CSS_TPG_MODE_RAMP) - isys_stream_descr->tpg_port_attr.mode = PIXELGEN_TPG_MODE_RAMP; - else if (stream_cfg->source.tpg.mode == IA_CSS_TPG_MODE_CHECKERBOARD) - isys_stream_descr->tpg_port_attr.mode = PIXELGEN_TPG_MODE_CHBO; - else if (stream_cfg->source.tpg.mode == IA_CSS_TPG_MODE_MONO) - isys_stream_descr->tpg_port_attr.mode = PIXELGEN_TPG_MODE_MONO; - else - rc = false; - - /* - * TODO - * - Make "color_cfg" as part of "ia_css_tpg_config". - */ - isys_stream_descr->tpg_port_attr.color_cfg.R1 = 51; - isys_stream_descr->tpg_port_attr.color_cfg.G1 = 102; - isys_stream_descr->tpg_port_attr.color_cfg.B1 = 255; - isys_stream_descr->tpg_port_attr.color_cfg.R2 = 0; - isys_stream_descr->tpg_port_attr.color_cfg.G2 = 100; - isys_stream_descr->tpg_port_attr.color_cfg.B2 = 160; - - isys_stream_descr->tpg_port_attr.mask_cfg.h_mask = - stream_cfg->source.tpg.x_mask; - isys_stream_descr->tpg_port_attr.mask_cfg.v_mask = - stream_cfg->source.tpg.y_mask; - isys_stream_descr->tpg_port_attr.mask_cfg.hv_mask = - stream_cfg->source.tpg.xy_mask; - - isys_stream_descr->tpg_port_attr.delta_cfg.h_delta = - stream_cfg->source.tpg.x_delta; - isys_stream_descr->tpg_port_attr.delta_cfg.v_delta = - stream_cfg->source.tpg.y_delta; - - /* - * TODO - * - Make "sync_gen_cfg" as part of "ia_css_tpg_config". - */ - isys_stream_descr->tpg_port_attr.sync_gen_cfg.hblank_cycles = 100; - isys_stream_descr->tpg_port_attr.sync_gen_cfg.vblank_cycles = 100; - isys_stream_descr->tpg_port_attr.sync_gen_cfg.pixels_per_clock = - stream_cfg->pixels_per_clock; - isys_stream_descr->tpg_port_attr.sync_gen_cfg.nr_of_frames = (uint32_t)~(0x0); - isys_stream_descr->tpg_port_attr.sync_gen_cfg.pixels_per_line = - stream_cfg->isys_config[IA_CSS_STREAM_DEFAULT_ISYS_STREAM_IDX].input_res.width; - isys_stream_descr->tpg_port_attr.sync_gen_cfg.lines_per_frame = - stream_cfg->isys_config[IA_CSS_STREAM_DEFAULT_ISYS_STREAM_IDX].input_res.height; - - break; case IA_CSS_INPUT_MODE_PRBS: isys_stream_descr->prbs_port_attr.seed0 = stream_cfg->source.prbs.seed; @@ -8153,23 +8084,6 @@ ia_css_stream_create(const struct ia_css_stream_config *stream_config, if (!IS_ISP2401) ia_css_stream_configure_rx(curr_stream); break; - case IA_CSS_INPUT_MODE_TPG: - if (!IS_ISP2401) { - IA_CSS_LOG("tpg_configuration: x_mask=%d, y_mask=%d, x_delta=%d, y_delta=%d, xy_mask=%d", - curr_stream->config.source.tpg.x_mask, - curr_stream->config.source.tpg.y_mask, - curr_stream->config.source.tpg.x_delta, - curr_stream->config.source.tpg.y_delta, - curr_stream->config.source.tpg.xy_mask); - - sh_css_sp_configure_tpg( - curr_stream->config.source.tpg.x_mask, - curr_stream->config.source.tpg.y_mask, - curr_stream->config.source.tpg.x_delta, - curr_stream->config.source.tpg.y_delta, - curr_stream->config.source.tpg.xy_mask); - } - break; case IA_CSS_INPUT_MODE_PRBS: if (!IS_ISP2401) { IA_CSS_LOG("mode prbs"); diff --git a/drivers/staging/media/atomisp/pci/sh_css_internal.h b/drivers/staging/media/atomisp/pci/sh_css_internal.h index 2349eb4d3767..bef2b8c5132b 100644 --- a/drivers/staging/media/atomisp/pci/sh_css_internal.h +++ b/drivers/staging/media/atomisp/pci/sh_css_internal.h @@ -360,7 +360,6 @@ struct sh_css_sp_config { } input_formatter; sync_generator_cfg_t sync_gen; - tpg_cfg_t tpg; prbs_cfg_t prbs; input_system_cfg_t input_circuit; u8 input_circuit_cfg_changed; diff --git a/drivers/staging/media/atomisp/pci/sh_css_sp.c b/drivers/staging/media/atomisp/pci/sh_css_sp.c index 55f9c89c6932..29e5bee78c20 100644 --- a/drivers/staging/media/atomisp/pci/sh_css_sp.c +++ b/drivers/staging/media/atomisp/pci/sh_css_sp.c @@ -669,20 +669,6 @@ sh_css_sp_configure_sync_gen(int width, int height, sh_css_sp_group.config.sync_gen.vblank_cycles = vblank_cycles; } -void -sh_css_sp_configure_tpg(int x_mask, - int y_mask, - int x_delta, - int y_delta, - int xy_mask) -{ - sh_css_sp_group.config.tpg.x_mask = x_mask; - sh_css_sp_group.config.tpg.y_mask = y_mask; - sh_css_sp_group.config.tpg.x_delta = x_delta; - sh_css_sp_group.config.tpg.y_delta = y_delta; - sh_css_sp_group.config.tpg.xy_mask = xy_mask; -} - void sh_css_sp_configure_prbs(int seed) { diff --git a/drivers/staging/media/atomisp/pci/sh_css_sp.h b/drivers/staging/media/atomisp/pci/sh_css_sp.h index 36b693bd916a..c12f57f5befc 100644 --- a/drivers/staging/media/atomisp/pci/sh_css_sp.h +++ b/drivers/staging/media/atomisp/pci/sh_css_sp.h @@ -164,13 +164,6 @@ sh_css_sp_configure_sync_gen(int width, int hblank_cycles, int vblank_cycles); -void -sh_css_sp_configure_tpg(int x_mask, - int y_mask, - int x_delta, - int y_delta, - int xy_mask); - void sh_css_sp_configure_prbs(int seed); -- cgit v1.2.3 From ca9ff7227931811fa13f197d6748a211419acd16 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Fri, 12 Apr 2024 19:38:55 +0100 Subject: media: atomisp: Remove input_port_ID_t Change the single, unexpected user of CSI_PORT0_ID for (port = CSI_PORT0_ID; port < N_CSI_PORTS; port++) to for (port = 0; port < N_CSI_PORTS; port++) { matching all the other for-loops iterating over the ports in the same file. And remove the now fully unused input_port_ID_t enum type. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/sh_css_mipi.c | 2 +- drivers/staging/media/atomisp/pci/system_global.h | 12 ------------ 2 files changed, 1 insertion(+), 13 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/sh_css_mipi.c b/drivers/staging/media/atomisp/pci/sh_css_mipi.c index 6e11fd771938..80f0395cc560 100644 --- a/drivers/staging/media/atomisp/pci/sh_css_mipi.c +++ b/drivers/staging/media/atomisp/pci/sh_css_mipi.c @@ -489,7 +489,7 @@ free_mipi_frames(struct ia_css_pipe *pipe) } } else { /* pipe ==NULL */ /* AM TEMP: free-ing all mipi buffers just like a legacy code. */ - for (port = CSI_PORT0_ID; port < N_CSI_PORTS; port++) { + for (port = 0; port < N_CSI_PORTS; port++) { unsigned int i; for (i = 0; i < my_css.num_mipi_frames[port]; i++) { diff --git a/drivers/staging/media/atomisp/pci/system_global.h b/drivers/staging/media/atomisp/pci/system_global.h index 060b924023ec..e8a29f73d67a 100644 --- a/drivers/staging/media/atomisp/pci/system_global.h +++ b/drivers/staging/media/atomisp/pci/system_global.h @@ -201,18 +201,6 @@ enum mipi_port_id { #define N_RX_CHANNEL_ID 4 -/* Generic port enumeration with an internal port type ID */ -typedef enum { - CSI_PORT0_ID = 0, - CSI_PORT1_ID, - CSI_PORT2_ID, - TPG_PORT0_ID, - PRBS_PORT0_ID, - FIFO_PORT0_ID, - MEMORY_PORT0_ID, - N_INPUT_PORT_ID -} input_port_ID_t; - typedef enum { CAPTURE_UNIT0_ID = 0, CAPTURE_UNIT1_ID, -- cgit v1.2.3 From f1aa35ab594321cad3855de844ec3837f08ad205 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sat, 13 Apr 2024 15:26:18 +0100 Subject: media: atomisp: Drop the atomisp custom lm3554 flash driver Drop the atomisp custom lm3554 flash driver, support for flash drivers using the custom atomisp flash interface is going to be removed from the atomisp driver. If flash supports for the lm3554 turns out to be necessary on some atomisp devices in the future then this should be re-implemented using the new include/linux/led-class-flash.h APIs. The atomisp specific lm3554 driver could still be usable as a reference for how to use / driver the lm3554 for a future re-implementation using standardized APIs, but for that it can be retrieved from the git history. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/i2c/Kconfig | 15 - drivers/staging/media/atomisp/i2c/Makefile | 5 - drivers/staging/media/atomisp/i2c/atomisp-lm3554.c | 955 --------------------- .../staging/media/atomisp/include/media/lm3554.h | 132 --- 4 files changed, 1107 deletions(-) delete mode 100644 drivers/staging/media/atomisp/i2c/atomisp-lm3554.c delete mode 100644 drivers/staging/media/atomisp/include/media/lm3554.h (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/i2c/Kconfig b/drivers/staging/media/atomisp/i2c/Kconfig index f62d183b787f..8710c483015c 100644 --- a/drivers/staging/media/atomisp/i2c/Kconfig +++ b/drivers/staging/media/atomisp/i2c/Kconfig @@ -56,18 +56,3 @@ config VIDEO_ATOMISP_GC0310 help This is a Video4Linux2 sensor-level driver for the Galaxycore GC0310 0.3MP sensor. - -# -# Kconfig for flash drivers -# - -config VIDEO_ATOMISP_LM3554 - tristate "LM3554 flash light driver" - depends on ACPI - depends on VIDEO_DEV && I2C - help - This is a Video4Linux2 sub-dev driver for the LM3554 - flash light driver. - - To compile this driver as a module, choose M here: the - module will be called lm3554 diff --git a/drivers/staging/media/atomisp/i2c/Makefile b/drivers/staging/media/atomisp/i2c/Makefile index e946cc91e5ff..3073cfa75ecf 100644 --- a/drivers/staging/media/atomisp/i2c/Makefile +++ b/drivers/staging/media/atomisp/i2c/Makefile @@ -9,8 +9,3 @@ obj-$(CONFIG_VIDEO_ATOMISP_OV2722) += atomisp-ov2722.o obj-$(CONFIG_VIDEO_ATOMISP_GC0310) += atomisp-gc0310.o obj-$(CONFIG_VIDEO_ATOMISP_MSRLIST_HELPER) += atomisp-libmsrlisthelper.o - -# Makefile for flash drivers -# - -obj-$(CONFIG_VIDEO_ATOMISP_LM3554) += atomisp-lm3554.o diff --git a/drivers/staging/media/atomisp/i2c/atomisp-lm3554.c b/drivers/staging/media/atomisp/i2c/atomisp-lm3554.c deleted file mode 100644 index cf5d9317b11a..000000000000 --- a/drivers/staging/media/atomisp/i2c/atomisp-lm3554.c +++ /dev/null @@ -1,955 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * LED flash driver for LM3554 - * - * Copyright (c) 2010-2012 Intel Corporation. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License version - * 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * - */ -#include -#include -#include -#include -#include -#include - -#include "../include/media/lm3554.h" -#include -#include -#include -#include "../include/linux/atomisp_gmin_platform.h" -#include "../include/linux/atomisp.h" - -/* Registers */ - -#define LM3554_TORCH_BRIGHTNESS_REG 0xA0 -#define LM3554_TORCH_MODE_SHIFT 0 -#define LM3554_TORCH_CURRENT_SHIFT 3 -#define LM3554_INDICATOR_CURRENT_SHIFT 6 - -#define LM3554_FLASH_BRIGHTNESS_REG 0xB0 -#define LM3554_FLASH_MODE_SHIFT 0 -#define LM3554_FLASH_CURRENT_SHIFT 3 -#define LM3554_STROBE_SENSITIVITY_SHIFT 7 - -#define LM3554_FLASH_DURATION_REG 0xC0 -#define LM3554_FLASH_TIMEOUT_SHIFT 0 -#define LM3554_CURRENT_LIMIT_SHIFT 5 - -#define LM3554_FLAGS_REG 0xD0 -#define LM3554_FLAG_TIMEOUT BIT(0) -#define LM3554_FLAG_THERMAL_SHUTDOWN BIT(1) -#define LM3554_FLAG_LED_FAULT BIT(2) -#define LM3554_FLAG_TX1_INTERRUPT BIT(3) -#define LM3554_FLAG_TX2_INTERRUPT BIT(4) -#define LM3554_FLAG_LED_THERMAL_FAULT BIT(5) -#define LM3554_FLAG_UNUSED BIT(6) -#define LM3554_FLAG_INPUT_VOLTAGE_LOW BIT(7) - -#define LM3554_CONFIG_REG_1 0xE0 -#define LM3554_ENVM_TX2_SHIFT 5 -#define LM3554_TX2_POLARITY_SHIFT 6 - -struct lm3554 { - struct v4l2_subdev sd; - - struct mutex power_lock; - struct v4l2_ctrl_handler ctrl_handler; - int power_count; - - unsigned int mode; - int timeout; - u8 torch_current; - u8 indicator_current; - u8 flash_current; - - struct timer_list flash_off_delay; - struct lm3554_platform_data *pdata; -}; - -#define to_lm3554(p_sd) container_of(p_sd, struct lm3554, sd) - -/* Return negative errno else zero on success */ -static int lm3554_write(struct lm3554 *flash, u8 addr, u8 val) -{ - struct i2c_client *client = v4l2_get_subdevdata(&flash->sd); - int ret; - - ret = i2c_smbus_write_byte_data(client, addr, val); - - dev_dbg(&client->dev, "Write Addr:%02X Val:%02X %s\n", addr, val, - ret < 0 ? "fail" : "ok"); - - return ret; -} - -/* Return negative errno else a data byte received from the device. */ -static int lm3554_read(struct lm3554 *flash, u8 addr) -{ - struct i2c_client *client = v4l2_get_subdevdata(&flash->sd); - int ret; - - ret = i2c_smbus_read_byte_data(client, addr); - - dev_dbg(&client->dev, "Read Addr:%02X Val:%02X %s\n", addr, ret, - ret < 0 ? "fail" : "ok"); - - return ret; -} - -/* ----------------------------------------------------------------------------- - * Hardware configuration - */ - -static int lm3554_set_mode(struct lm3554 *flash, unsigned int mode) -{ - u8 val; - int ret; - - val = (mode << LM3554_FLASH_MODE_SHIFT) | - (flash->flash_current << LM3554_FLASH_CURRENT_SHIFT); - - ret = lm3554_write(flash, LM3554_FLASH_BRIGHTNESS_REG, val); - if (ret == 0) - flash->mode = mode; - return ret; -} - -static int lm3554_set_torch(struct lm3554 *flash) -{ - u8 val; - - val = (flash->mode << LM3554_TORCH_MODE_SHIFT) | - (flash->torch_current << LM3554_TORCH_CURRENT_SHIFT) | - (flash->indicator_current << LM3554_INDICATOR_CURRENT_SHIFT); - - return lm3554_write(flash, LM3554_TORCH_BRIGHTNESS_REG, val); -} - -static int lm3554_set_flash(struct lm3554 *flash) -{ - u8 val; - - val = (flash->mode << LM3554_FLASH_MODE_SHIFT) | - (flash->flash_current << LM3554_FLASH_CURRENT_SHIFT); - - return lm3554_write(flash, LM3554_FLASH_BRIGHTNESS_REG, val); -} - -static int lm3554_set_duration(struct lm3554 *flash) -{ - u8 val; - - val = (flash->timeout << LM3554_FLASH_TIMEOUT_SHIFT) | - (flash->pdata->current_limit << LM3554_CURRENT_LIMIT_SHIFT); - - return lm3554_write(flash, LM3554_FLASH_DURATION_REG, val); -} - -static int lm3554_set_config1(struct lm3554 *flash) -{ - u8 val; - - val = (flash->pdata->envm_tx2 << LM3554_ENVM_TX2_SHIFT) | - (flash->pdata->tx2_polarity << LM3554_TX2_POLARITY_SHIFT); - return lm3554_write(flash, LM3554_CONFIG_REG_1, val); -} - -/* ----------------------------------------------------------------------------- - * Hardware trigger - */ -static void lm3554_flash_off_delay(struct timer_list *t) -{ - struct lm3554 *flash = from_timer(flash, t, flash_off_delay); - struct lm3554_platform_data *pdata = flash->pdata; - - gpiod_set_value(pdata->gpio_strobe, 0); -} - -static int lm3554_hw_strobe(struct i2c_client *client, bool strobe) -{ - int ret, timer_pending; - struct v4l2_subdev *sd = i2c_get_clientdata(client); - struct lm3554 *flash = to_lm3554(sd); - struct lm3554_platform_data *pdata = flash->pdata; - - /* - * An abnormal high flash current is observed when strobe off the - * flash. Workaround here is firstly set flash current to lower level, - * wait a short moment, and then strobe off the flash. - */ - - timer_pending = del_timer_sync(&flash->flash_off_delay); - - /* Flash off */ - if (!strobe) { - /* set current to 70mA and wait a while */ - ret = lm3554_write(flash, LM3554_FLASH_BRIGHTNESS_REG, 0); - if (ret < 0) - goto err; - mod_timer(&flash->flash_off_delay, - jiffies + msecs_to_jiffies(LM3554_TIMER_DELAY)); - return 0; - } - - /* Flash on */ - - /* - * If timer is killed before run, flash is not strobe off, - * so must strobe off here - */ - if (timer_pending) - gpiod_set_value(pdata->gpio_strobe, 0); - - /* Restore flash current settings */ - ret = lm3554_set_flash(flash); - if (ret < 0) - goto err; - - /* Strobe on Flash */ - gpiod_set_value(pdata->gpio_strobe, 1); - - return 0; -err: - dev_err(&client->dev, "failed to %s flash strobe (%d)\n", - strobe ? "on" : "off", ret); - return ret; -} - -/* ----------------------------------------------------------------------------- - * V4L2 controls - */ - -static int lm3554_read_status(struct lm3554 *flash) -{ - int ret; - struct i2c_client *client = v4l2_get_subdevdata(&flash->sd); - - /* NOTE: reading register clear fault status */ - ret = lm3554_read(flash, LM3554_FLAGS_REG); - if (ret < 0) - return ret; - - /* - * Accordingly to datasheet we read back '1' in bit 6. - * Clear it first. - */ - ret &= ~LM3554_FLAG_UNUSED; - - /* - * Do not take TX1/TX2 signal as an error - * because MSIC will not turn off flash, but turn to - * torch mode according to gsm modem signal by hardware. - */ - ret &= ~(LM3554_FLAG_TX1_INTERRUPT | LM3554_FLAG_TX2_INTERRUPT); - - if (ret > 0) - dev_dbg(&client->dev, "LM3554 flag status: %02x\n", ret); - - return ret; -} - -static int lm3554_s_flash_timeout(struct v4l2_subdev *sd, u32 val) -{ - struct lm3554 *flash = to_lm3554(sd); - - val = clamp(val, LM3554_MIN_TIMEOUT, LM3554_MAX_TIMEOUT); - val = val / LM3554_TIMEOUT_STEPSIZE - 1; - - flash->timeout = val; - - return lm3554_set_duration(flash); -} - -static int lm3554_g_flash_timeout(struct v4l2_subdev *sd, s32 *val) -{ - struct lm3554 *flash = to_lm3554(sd); - - *val = (u32)(flash->timeout + 1) * LM3554_TIMEOUT_STEPSIZE; - - return 0; -} - -static int lm3554_s_flash_intensity(struct v4l2_subdev *sd, u32 intensity) -{ - struct lm3554 *flash = to_lm3554(sd); - - intensity = LM3554_CLAMP_PERCENTAGE(intensity); - intensity = LM3554_PERCENT_TO_VALUE(intensity, LM3554_FLASH_STEP); - - flash->flash_current = intensity; - - return lm3554_set_flash(flash); -} - -static int lm3554_g_flash_intensity(struct v4l2_subdev *sd, s32 *val) -{ - struct lm3554 *flash = to_lm3554(sd); - - *val = LM3554_VALUE_TO_PERCENT((u32)flash->flash_current, - LM3554_FLASH_STEP); - - return 0; -} - -static int lm3554_s_torch_intensity(struct v4l2_subdev *sd, u32 intensity) -{ - struct lm3554 *flash = to_lm3554(sd); - - intensity = LM3554_CLAMP_PERCENTAGE(intensity); - intensity = LM3554_PERCENT_TO_VALUE(intensity, LM3554_TORCH_STEP); - - flash->torch_current = intensity; - - return lm3554_set_torch(flash); -} - -static int lm3554_g_torch_intensity(struct v4l2_subdev *sd, s32 *val) -{ - struct lm3554 *flash = to_lm3554(sd); - - *val = LM3554_VALUE_TO_PERCENT((u32)flash->torch_current, - LM3554_TORCH_STEP); - - return 0; -} - -static int lm3554_s_indicator_intensity(struct v4l2_subdev *sd, u32 intensity) -{ - struct lm3554 *flash = to_lm3554(sd); - - intensity = LM3554_CLAMP_PERCENTAGE(intensity); - intensity = LM3554_PERCENT_TO_VALUE(intensity, LM3554_INDICATOR_STEP); - - flash->indicator_current = intensity; - - return lm3554_set_torch(flash); -} - -static int lm3554_g_indicator_intensity(struct v4l2_subdev *sd, s32 *val) -{ - struct lm3554 *flash = to_lm3554(sd); - - *val = LM3554_VALUE_TO_PERCENT((u32)flash->indicator_current, - LM3554_INDICATOR_STEP); - - return 0; -} - -static int lm3554_s_flash_strobe(struct v4l2_subdev *sd, u32 val) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - - return lm3554_hw_strobe(client, val); -} - -static int lm3554_s_flash_mode(struct v4l2_subdev *sd, u32 new_mode) -{ - struct lm3554 *flash = to_lm3554(sd); - unsigned int mode; - - switch (new_mode) { - case ATOMISP_FLASH_MODE_OFF: - mode = LM3554_MODE_SHUTDOWN; - break; - case ATOMISP_FLASH_MODE_FLASH: - mode = LM3554_MODE_FLASH; - break; - case ATOMISP_FLASH_MODE_INDICATOR: - mode = LM3554_MODE_INDICATOR; - break; - case ATOMISP_FLASH_MODE_TORCH: - mode = LM3554_MODE_TORCH; - break; - default: - return -EINVAL; - } - - return lm3554_set_mode(flash, mode); -} - -static int lm3554_g_flash_mode(struct v4l2_subdev *sd, s32 *val) -{ - struct lm3554 *flash = to_lm3554(sd); - *val = flash->mode; - return 0; -} - -static int lm3554_g_flash_status(struct v4l2_subdev *sd, s32 *val) -{ - struct lm3554 *flash = to_lm3554(sd); - int value; - - value = lm3554_read_status(flash); - if (value < 0) - return value; - - if (value & LM3554_FLAG_TIMEOUT) - *val = ATOMISP_FLASH_STATUS_TIMEOUT; - else if (value > 0) - *val = ATOMISP_FLASH_STATUS_HW_ERROR; - else - *val = ATOMISP_FLASH_STATUS_OK; - - return 0; -} - -static int lm3554_g_flash_status_register(struct v4l2_subdev *sd, s32 *val) -{ - struct lm3554 *flash = to_lm3554(sd); - int ret; - - ret = lm3554_read(flash, LM3554_FLAGS_REG); - - if (ret < 0) - return ret; - - *val = ret; - return 0; -} - -static int lm3554_s_ctrl(struct v4l2_ctrl *ctrl) -{ - struct lm3554 *dev = - container_of(ctrl->handler, struct lm3554, ctrl_handler); - int ret = 0; - - switch (ctrl->id) { - case V4L2_CID_FLASH_TIMEOUT: - ret = lm3554_s_flash_timeout(&dev->sd, ctrl->val); - break; - case V4L2_CID_FLASH_INTENSITY: - ret = lm3554_s_flash_intensity(&dev->sd, ctrl->val); - break; - case V4L2_CID_FLASH_TORCH_INTENSITY: - ret = lm3554_s_torch_intensity(&dev->sd, ctrl->val); - break; - case V4L2_CID_FLASH_INDICATOR_INTENSITY: - ret = lm3554_s_indicator_intensity(&dev->sd, ctrl->val); - break; - case V4L2_CID_FLASH_STROBE: - ret = lm3554_s_flash_strobe(&dev->sd, ctrl->val); - break; - case V4L2_CID_FLASH_MODE: - ret = lm3554_s_flash_mode(&dev->sd, ctrl->val); - break; - default: - ret = -EINVAL; - } - return ret; -} - -static int lm3554_g_volatile_ctrl(struct v4l2_ctrl *ctrl) -{ - struct lm3554 *dev = - container_of(ctrl->handler, struct lm3554, ctrl_handler); - int ret = 0; - - switch (ctrl->id) { - case V4L2_CID_FLASH_TIMEOUT: - ret = lm3554_g_flash_timeout(&dev->sd, &ctrl->val); - break; - case V4L2_CID_FLASH_INTENSITY: - ret = lm3554_g_flash_intensity(&dev->sd, &ctrl->val); - break; - case V4L2_CID_FLASH_TORCH_INTENSITY: - ret = lm3554_g_torch_intensity(&dev->sd, &ctrl->val); - break; - case V4L2_CID_FLASH_INDICATOR_INTENSITY: - ret = lm3554_g_indicator_intensity(&dev->sd, &ctrl->val); - break; - case V4L2_CID_FLASH_MODE: - ret = lm3554_g_flash_mode(&dev->sd, &ctrl->val); - break; - case V4L2_CID_FLASH_STATUS: - ret = lm3554_g_flash_status(&dev->sd, &ctrl->val); - break; - case V4L2_CID_FLASH_STATUS_REGISTER: - ret = lm3554_g_flash_status_register(&dev->sd, &ctrl->val); - break; - default: - ret = -EINVAL; - } - - return ret; -} - -static const struct v4l2_ctrl_ops ctrl_ops = { - .s_ctrl = lm3554_s_ctrl, - .g_volatile_ctrl = lm3554_g_volatile_ctrl -}; - -static const struct v4l2_ctrl_config lm3554_controls[] = { - { - .ops = &ctrl_ops, - .id = V4L2_CID_FLASH_TIMEOUT, - .type = V4L2_CTRL_TYPE_INTEGER, - .name = "Flash Timeout", - .min = 0x0, - .max = LM3554_MAX_TIMEOUT, - .step = 0x01, - .def = LM3554_DEFAULT_TIMEOUT, - .flags = 0, - }, - { - .ops = &ctrl_ops, - .id = V4L2_CID_FLASH_INTENSITY, - .type = V4L2_CTRL_TYPE_INTEGER, - .name = "Flash Intensity", - .min = LM3554_MIN_PERCENT, - .max = LM3554_MAX_PERCENT, - .step = 0x01, - .def = LM3554_FLASH_DEFAULT_BRIGHTNESS, - .flags = 0, - }, - { - .ops = &ctrl_ops, - .id = V4L2_CID_FLASH_TORCH_INTENSITY, - .type = V4L2_CTRL_TYPE_INTEGER, - .name = "Torch Intensity", - .min = LM3554_MIN_PERCENT, - .max = LM3554_MAX_PERCENT, - .step = 0x01, - .def = LM3554_TORCH_DEFAULT_BRIGHTNESS, - .flags = 0, - }, - { - .ops = &ctrl_ops, - .id = V4L2_CID_FLASH_INDICATOR_INTENSITY, - .type = V4L2_CTRL_TYPE_INTEGER, - .name = "Indicator Intensity", - .min = LM3554_MIN_PERCENT, - .max = LM3554_MAX_PERCENT, - .step = 0x01, - .def = LM3554_INDICATOR_DEFAULT_BRIGHTNESS, - .flags = 0, - }, - { - .ops = &ctrl_ops, - .id = V4L2_CID_FLASH_STROBE, - .type = V4L2_CTRL_TYPE_BOOLEAN, - .name = "Flash Strobe", - .min = 0, - .max = 1, - .step = 1, - .def = 0, - .flags = 0, - }, - { - .ops = &ctrl_ops, - .id = V4L2_CID_FLASH_MODE, - .type = V4L2_CTRL_TYPE_INTEGER, - .name = "Flash Mode", - .min = 0, - .max = 100, - .step = 1, - .def = ATOMISP_FLASH_MODE_OFF, - .flags = 0, - }, - { - .ops = &ctrl_ops, - .id = V4L2_CID_FLASH_STATUS, - .type = V4L2_CTRL_TYPE_INTEGER, - .name = "Flash Status", - .min = ATOMISP_FLASH_STATUS_OK, - .max = ATOMISP_FLASH_STATUS_TIMEOUT, - .step = 1, - .def = ATOMISP_FLASH_STATUS_OK, - .flags = 0, - }, - { - .ops = &ctrl_ops, - .id = V4L2_CID_FLASH_STATUS_REGISTER, - .type = V4L2_CTRL_TYPE_INTEGER, - .name = "Flash Status Register", - .min = 0, - .max = 255, - .step = 1, - .def = 0, - .flags = 0, - }, -}; - -/* ----------------------------------------------------------------------------- - * V4L2 subdev core operations - */ - -/* Put device into known state. */ -static int lm3554_setup(struct lm3554 *flash) -{ - struct i2c_client *client = v4l2_get_subdevdata(&flash->sd); - int ret; - - /* clear the flags register */ - ret = lm3554_read(flash, LM3554_FLAGS_REG); - if (ret < 0) - return ret; - - dev_dbg(&client->dev, "Fault info: %02x\n", ret); - - ret = lm3554_set_config1(flash); - if (ret < 0) - return ret; - - ret = lm3554_set_duration(flash); - if (ret < 0) - return ret; - - ret = lm3554_set_torch(flash); - if (ret < 0) - return ret; - - ret = lm3554_set_flash(flash); - if (ret < 0) - return ret; - - /* read status */ - ret = lm3554_read_status(flash); - if (ret < 0) - return ret; - - return ret ? -EIO : 0; -} - -static int __lm3554_s_power(struct lm3554 *flash, int power) -{ - struct lm3554_platform_data *pdata = flash->pdata; - int ret; - - /*initialize flash driver*/ - gpiod_set_value(pdata->gpio_reset, power); - usleep_range(100, 100 + 1); - - if (power) { - /* Setup default values. This makes sure that the chip - * is in a known state. - */ - ret = lm3554_setup(flash); - if (ret < 0) { - __lm3554_s_power(flash, 0); - return ret; - } - } - - return 0; -} - -static int lm3554_s_power(struct v4l2_subdev *sd, int power) -{ - struct lm3554 *flash = to_lm3554(sd); - int ret = 0; - - mutex_lock(&flash->power_lock); - - if (flash->power_count == !power) { - ret = __lm3554_s_power(flash, !!power); - if (ret < 0) - goto done; - } - - flash->power_count += power ? 1 : -1; - WARN_ON(flash->power_count < 0); - -done: - mutex_unlock(&flash->power_lock); - return ret; -} - -static const struct v4l2_subdev_core_ops lm3554_core_ops = { - .s_power = lm3554_s_power, -}; - -static const struct v4l2_subdev_ops lm3554_ops = { - .core = &lm3554_core_ops, -}; - -static int lm3554_detect(struct v4l2_subdev *sd) -{ - struct i2c_client *client = v4l2_get_subdevdata(sd); - struct i2c_adapter *adapter = client->adapter; - struct lm3554 *flash = to_lm3554(sd); - int ret; - - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { - dev_err(&client->dev, "lm3554_detect i2c error\n"); - return -ENODEV; - } - - /* Power up the flash driver and reset it */ - ret = lm3554_s_power(&flash->sd, 1); - if (ret < 0) { - dev_err(&client->dev, "Failed to power on lm3554 LED flash\n"); - } else { - dev_dbg(&client->dev, "Successfully detected lm3554 LED flash\n"); - lm3554_s_power(&flash->sd, 0); - } - - return ret; -} - -static int lm3554_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) -{ - return lm3554_s_power(sd, 1); -} - -static int lm3554_close(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) -{ - return lm3554_s_power(sd, 0); -} - -static const struct v4l2_subdev_internal_ops lm3554_internal_ops = { - .registered = lm3554_detect, - .open = lm3554_open, - .close = lm3554_close, -}; - -/* ----------------------------------------------------------------------------- - * I2C driver - */ -#ifdef CONFIG_PM - -static int lm3554_suspend(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct v4l2_subdev *subdev = i2c_get_clientdata(client); - struct lm3554 *flash = to_lm3554(subdev); - int rval; - - if (flash->power_count == 0) - return 0; - - rval = __lm3554_s_power(flash, 0); - - dev_dbg(&client->dev, "Suspend %s\n", rval < 0 ? "failed" : "ok"); - - return rval; -} - -static int lm3554_resume(struct device *dev) -{ - struct i2c_client *client = to_i2c_client(dev); - struct v4l2_subdev *subdev = i2c_get_clientdata(client); - struct lm3554 *flash = to_lm3554(subdev); - int rval; - - if (flash->power_count == 0) - return 0; - - rval = __lm3554_s_power(flash, 1); - - dev_dbg(&client->dev, "Resume %s\n", rval < 0 ? "fail" : "ok"); - - return rval; -} - -#else - -#define lm3554_suspend NULL -#define lm3554_resume NULL - -#endif /* CONFIG_PM */ - -static int lm3554_gpio_init(struct i2c_client *client) -{ - struct v4l2_subdev *sd = i2c_get_clientdata(client); - struct lm3554 *flash = to_lm3554(sd); - struct lm3554_platform_data *pdata = flash->pdata; - int ret; - - if (!pdata->gpio_reset) - return -EINVAL; - - ret = gpiod_direction_output(pdata->gpio_reset, 0); - if (ret < 0) - return ret; - - if (!pdata->gpio_strobe) - return -EINVAL; - - ret = gpiod_direction_output(pdata->gpio_strobe, 0); - if (ret < 0) - return ret; - - return 0; -} - -static void lm3554_gpio_uninit(struct i2c_client *client) -{ - struct v4l2_subdev *sd = i2c_get_clientdata(client); - struct lm3554 *flash = to_lm3554(sd); - struct lm3554_platform_data *pdata = flash->pdata; - int ret; - - ret = gpiod_direction_output(pdata->gpio_strobe, 0); - if (ret < 0) - dev_err(&client->dev, - "gpio request/direction_output fail for gpio_strobe"); - - ret = gpiod_direction_output(pdata->gpio_reset, 0); - if (ret < 0) - dev_err(&client->dev, - "gpio request/direction_output fail for gpio_reset"); -} - -static void *lm3554_platform_data_func(struct i2c_client *client) -{ - static struct lm3554_platform_data platform_data; - - platform_data.gpio_reset = gpiod_get_index(&client->dev, - NULL, 2, GPIOD_OUT_LOW); - if (IS_ERR(platform_data.gpio_reset)) - return ERR_CAST(platform_data.gpio_reset); - platform_data.gpio_strobe = gpiod_get_index(&client->dev, - NULL, 0, GPIOD_OUT_LOW); - if (IS_ERR(platform_data.gpio_strobe)) - return ERR_CAST(platform_data.gpio_strobe); - platform_data.gpio_torch = gpiod_get_index(&client->dev, - NULL, 1, GPIOD_OUT_LOW); - if (IS_ERR(platform_data.gpio_torch)) - return ERR_CAST(platform_data.gpio_torch); - - /* Set to TX2 mode, then ENVM/TX2 pin is a power amplifier sync input: - * ENVM/TX pin asserted, flash forced into torch; - * ENVM/TX pin desserted, flash set back; - */ - platform_data.envm_tx2 = 1; - platform_data.tx2_polarity = 0; - - /* set peak current limit to be 1000mA */ - platform_data.current_limit = 0; - - return &platform_data; -} - -static int lm3554_probe(struct i2c_client *client) -{ - int err = 0; - struct lm3554 *flash; - unsigned int i; - - flash = kzalloc(sizeof(*flash), GFP_KERNEL); - if (!flash) - return -ENOMEM; - - flash->pdata = lm3554_platform_data_func(client); - if (IS_ERR(flash->pdata)) { - err = PTR_ERR(flash->pdata); - goto free_flash; - } - - v4l2_i2c_subdev_init(&flash->sd, client, &lm3554_ops); - flash->sd.internal_ops = &lm3554_internal_ops; - flash->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; - flash->mode = ATOMISP_FLASH_MODE_OFF; - flash->timeout = LM3554_MAX_TIMEOUT / LM3554_TIMEOUT_STEPSIZE - 1; - err = - v4l2_ctrl_handler_init(&flash->ctrl_handler, - ARRAY_SIZE(lm3554_controls)); - if (err) { - dev_err(&client->dev, "error initialize a ctrl_handler.\n"); - goto unregister_subdev; - } - - for (i = 0; i < ARRAY_SIZE(lm3554_controls); i++) - v4l2_ctrl_new_custom(&flash->ctrl_handler, &lm3554_controls[i], - NULL); - - if (flash->ctrl_handler.error) { - dev_err(&client->dev, "ctrl_handler error.\n"); - err = flash->ctrl_handler.error; - goto free_handler; - } - - flash->sd.ctrl_handler = &flash->ctrl_handler; - err = media_entity_pads_init(&flash->sd.entity, 0, NULL); - if (err) { - dev_err(&client->dev, "error initialize a media entity.\n"); - goto free_handler; - } - - flash->sd.entity.function = MEDIA_ENT_F_FLASH; - - mutex_init(&flash->power_lock); - - timer_setup(&flash->flash_off_delay, lm3554_flash_off_delay, 0); - - err = lm3554_gpio_init(client); - if (err) { - dev_err(&client->dev, "gpio request/direction_output fail.\n"); - goto cleanup_media; - } - - err = atomisp_register_i2c_module(&flash->sd, NULL, LED_FLASH); - if (err) { - dev_err(&client->dev, "fail to register atomisp i2c module.\n"); - goto uninit_gpio; - } - - return 0; - -uninit_gpio: - lm3554_gpio_uninit(client); -cleanup_media: - media_entity_cleanup(&flash->sd.entity); -free_handler: - v4l2_ctrl_handler_free(&flash->ctrl_handler); -unregister_subdev: - v4l2_device_unregister_subdev(&flash->sd); -free_flash: - kfree(flash); - - return err; -} - -static void lm3554_remove(struct i2c_client *client) -{ - struct v4l2_subdev *sd = i2c_get_clientdata(client); - struct lm3554 *flash = to_lm3554(sd); - - media_entity_cleanup(&flash->sd.entity); - v4l2_ctrl_handler_free(&flash->ctrl_handler); - v4l2_device_unregister_subdev(sd); - - atomisp_gmin_remove_subdev(sd); - - timer_shutdown_sync(&flash->flash_off_delay); - - lm3554_gpio_uninit(client); - - kfree(flash); -} - -static const struct dev_pm_ops lm3554_pm_ops = { - .suspend = lm3554_suspend, - .resume = lm3554_resume, -}; - -static const struct acpi_device_id lm3554_acpi_match[] = { - { "INTCF1C" }, - {}, -}; -MODULE_DEVICE_TABLE(acpi, lm3554_acpi_match); - -static struct i2c_driver lm3554_driver = { - .driver = { - .name = "lm3554", - .pm = &lm3554_pm_ops, - .acpi_match_table = lm3554_acpi_match, - }, - .probe = lm3554_probe, - .remove = lm3554_remove, -}; -module_i2c_driver(lm3554_driver); - -MODULE_AUTHOR("Jing Tao "); -MODULE_DESCRIPTION("LED flash driver for LM3554"); -MODULE_LICENSE("GPL"); diff --git a/drivers/staging/media/atomisp/include/media/lm3554.h b/drivers/staging/media/atomisp/include/media/lm3554.h deleted file mode 100644 index 711b7d7c9950..000000000000 --- a/drivers/staging/media/atomisp/include/media/lm3554.h +++ /dev/null @@ -1,132 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * include/media/lm3554.h - * - * Copyright (c) 2010-2012 Intel Corporation. All Rights Reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License version - * 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * - */ -#ifndef _LM3554_H_ -#define _LM3554_H_ - -#include -#include -#include - -#define LM3554_ID 3554 - -#define v4l2_queryctrl_entry_integer(_id, _name,\ - _minimum, _maximum, _step, \ - _default_value, _flags) \ - {\ - .id = (_id), \ - .type = V4L2_CTRL_TYPE_INTEGER, \ - .name = _name, \ - .minimum = (_minimum), \ - .maximum = (_maximum), \ - .step = (_step), \ - .default_value = (_default_value),\ - .flags = (_flags),\ - } -#define v4l2_queryctrl_entry_boolean(_id, _name,\ - _default_value, _flags) \ - {\ - .id = (_id), \ - .type = V4L2_CTRL_TYPE_BOOLEAN, \ - .name = _name, \ - .minimum = 0, \ - .maximum = 1, \ - .step = 1, \ - .default_value = (_default_value),\ - .flags = (_flags),\ - } - -#define s_ctrl_id_entry_integer(_id, _name, \ - _minimum, _maximum, _step, \ - _default_value, _flags, \ - _s_ctrl, _g_ctrl) \ - {\ - .qc = v4l2_queryctrl_entry_integer(_id, _name,\ - _minimum, _maximum, _step,\ - _default_value, _flags), \ - .s_ctrl = _s_ctrl, \ - .g_ctrl = _g_ctrl, \ - } - -#define s_ctrl_id_entry_boolean(_id, _name, \ - _default_value, _flags, \ - _s_ctrl, _g_ctrl) \ - {\ - .qc = v4l2_queryctrl_entry_boolean(_id, _name,\ - _default_value, _flags), \ - .s_ctrl = _s_ctrl, \ - .g_ctrl = _g_ctrl, \ - } - -/* Value settings for Flash Time-out Duration*/ -#define LM3554_DEFAULT_TIMEOUT 512U -#define LM3554_MIN_TIMEOUT 32U -#define LM3554_MAX_TIMEOUT 1024U -#define LM3554_TIMEOUT_STEPSIZE 32U - -/* Flash modes */ -#define LM3554_MODE_SHUTDOWN 0 -#define LM3554_MODE_INDICATOR 1 -#define LM3554_MODE_TORCH 2 -#define LM3554_MODE_FLASH 3 - -/* timer delay time */ -#define LM3554_TIMER_DELAY 5 - -/* Percentage <-> value macros */ -#define LM3554_MIN_PERCENT 0U -#define LM3554_MAX_PERCENT 100U -#define LM3554_CLAMP_PERCENTAGE(val) \ - clamp(val, LM3554_MIN_PERCENT, LM3554_MAX_PERCENT) - -#define LM3554_VALUE_TO_PERCENT(v, step) (((((unsigned long)(v)) * (step)) + 50) / 100) -#define LM3554_PERCENT_TO_VALUE(p, step) (((((unsigned long)(p)) * 100) + (step >> 1)) / (step)) - -/* Product specific limits - * TODO: get these from platform data */ -#define LM3554_FLASH_MAX_LVL 0x0F /* 1191mA */ - -/* Flash brightness, input is percentage, output is [0..15] */ -#define LM3554_FLASH_STEP \ - ((100ul * (LM3554_MAX_PERCENT) + ((LM3554_FLASH_MAX_LVL) >> 1)) / ((LM3554_FLASH_MAX_LVL))) -#define LM3554_FLASH_DEFAULT_BRIGHTNESS \ - LM3554_VALUE_TO_PERCENT(13, LM3554_FLASH_STEP) - -/* Torch brightness, input is percentage, output is [0..7] */ -#define LM3554_TORCH_STEP 1250 -#define LM3554_TORCH_DEFAULT_BRIGHTNESS \ - LM3554_VALUE_TO_PERCENT(2, LM3554_TORCH_STEP) - -/* Indicator brightness, input is percentage, output is [0..3] */ -#define LM3554_INDICATOR_STEP 2500 -#define LM3554_INDICATOR_DEFAULT_BRIGHTNESS \ - LM3554_VALUE_TO_PERCENT(1, LM3554_INDICATOR_STEP) - -/* - * lm3554_platform_data - Flash controller platform data - */ -struct lm3554_platform_data { - struct gpio_desc *gpio_torch; - struct gpio_desc *gpio_strobe; - struct gpio_desc *gpio_reset; - - unsigned int current_limit; - unsigned int envm_tx2; - unsigned int tx2_polarity; -}; - -#endif /* _LM3554_H_ */ -- cgit v1.2.3 From f468ff16f5524cdccf182a1fa7c0558421d2acbc Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sat, 13 Apr 2024 16:10:41 +0100 Subject: media: atomisp: Drop custom flash support Remove the custom flash handling from the atomisp driver. There are only few Bay Trail / Cherry Trail devices with flash and if those will ever get supported then this should be done through the new standard include/linux/led-class-flash.h APIs instead of with atomisp specific custom APIs. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- .../staging/media/atomisp/include/linux/atomisp.h | 42 -------- .../media/atomisp/include/linux/atomisp_platform.h | 1 - drivers/staging/media/atomisp/pci/atomisp_cmd.c | 117 +-------------------- drivers/staging/media/atomisp/pci/atomisp_cmd.h | 4 - drivers/staging/media/atomisp/pci/atomisp_fops.c | 14 --- .../staging/media/atomisp/pci/atomisp_internal.h | 1 - drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 61 ----------- drivers/staging/media/atomisp/pci/atomisp_subdev.h | 13 --- drivers/staging/media/atomisp/pci/atomisp_v4l2.c | 7 -- .../media/atomisp/pci/ia_css_frame_public.h | 8 -- .../media/atomisp/pci/ia_css_stream_public.h | 14 --- drivers/staging/media/atomisp/pci/sh_css.c | 33 ------ 12 files changed, 2 insertions(+), 313 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/include/linux/atomisp.h b/drivers/staging/media/atomisp/include/linux/atomisp.h index b2735a008052..db0c1b87c9ef 100644 --- a/drivers/staging/media/atomisp/include/linux/atomisp.h +++ b/drivers/staging/media/atomisp/include/linux/atomisp.h @@ -614,26 +614,6 @@ enum atomisp_camera_port { ATOMISP_CAMERA_NR_PORTS }; -/* Flash modes. Default is off. - * Setting a flash to TORCH or INDICATOR mode will automatically - * turn it on. Setting it to FLASH mode will not turn on the flash - * until the FLASH_STROBE command is sent. */ -enum atomisp_flash_mode { - ATOMISP_FLASH_MODE_OFF, - ATOMISP_FLASH_MODE_FLASH, - ATOMISP_FLASH_MODE_TORCH, - ATOMISP_FLASH_MODE_INDICATOR, -}; - -/* Flash statuses, used by atomisp driver to check before starting - * flash and after having started flash. */ -enum atomisp_flash_status { - ATOMISP_FLASH_STATUS_OK, - ATOMISP_FLASH_STATUS_HW_ERROR, - ATOMISP_FLASH_STATUS_INTERRUPTED, - ATOMISP_FLASH_STATUS_TIMEOUT, -}; - /* Frame status. This is used to detect corrupted frames and flash * exposed frames. Usually, the first 2 frames coming out of the sensor * are corrupted. When using flash, the frame before and the frame after @@ -661,7 +641,6 @@ enum atomisp_ext_isp_id { EXT_ISP_CID_AF_STATUS, EXT_ISP_CID_GET_AF_MODE, EXT_ISP_CID_CAPTURE_BURST, - EXT_ISP_CID_FLASH_MODE, EXT_ISP_CID_ZOOM, EXT_ISP_CID_SHOT_MODE }; @@ -694,12 +673,6 @@ enum atomisp_burst_capture_options { EXT_ISP_BURST_CAPTURE_CTRL_STOP }; -#define EXT_ISP_FLASH_MODE_OFF 0 -#define EXT_ISP_FLASH_MODE_ON 1 -#define EXT_ISP_FLASH_MODE_AUTO 2 -#define EXT_ISP_LED_TORCH_OFF 3 -#define EXT_ISP_LED_TORCH_ON 4 - #define EXT_ISP_SHOT_MODE_AUTO 0 #define EXT_ISP_SHOT_MODE_BEAUTY_FACE 1 #define EXT_ISP_SHOT_MODE_BEST_PHOTO 2 @@ -894,18 +867,6 @@ enum atomisp_burst_capture_options { * Exposure, Flash and privacy (indicator) light controls, to be upstreamed */ #define V4L2_CID_CAMERA_LASTP1 (V4L2_CID_CAMERA_CLASS_BASE + 1024) -/* Flash related CIDs, see also: - * http://linuxtv.org/downloads/v4l-dvb-apis/extended-controls.html\ - * #flash-controls */ - -/* Request a number of flash-exposed frames. The frame status can be - * found in the reserved field in the v4l2_buffer struct. */ -#define V4L2_CID_REQUEST_FLASH (V4L2_CID_CAMERA_LASTP1 + 3) -/* Query flash driver status. See enum atomisp_flash_status above. */ -#define V4L2_CID_FLASH_STATUS (V4L2_CID_CAMERA_LASTP1 + 5) -/* Set the flash mode (see enum atomisp_flash_mode) */ -#define V4L2_CID_FLASH_MODE (V4L2_CID_CAMERA_LASTP1 + 10) - #define V4L2_CID_RUN_MODE (V4L2_CID_CAMERA_LASTP1 + 20) #define ATOMISP_RUN_MODE_VIDEO 1 #define ATOMISP_RUN_MODE_STILL_CAPTURE 2 @@ -925,9 +886,6 @@ enum atomisp_burst_capture_options { #define ATOMISP_VFPP_DISABLE_SCALER 1 #define ATOMISP_VFPP_DISABLE_LOWLAT 2 -/* Query real flash status register value */ -#define V4L2_CID_FLASH_STATUS_REGISTER (V4L2_CID_CAMERA_LASTP1 + 26) - #define V4L2_CID_START_ZSL_CAPTURE (V4L2_CID_CAMERA_LASTP1 + 28) /* Lock and unlock raw buffer */ #define V4L2_CID_ENABLE_RAW_BUFFER_LOCK (V4L2_CID_CAMERA_LASTP1 + 29) diff --git a/drivers/staging/media/atomisp/include/linux/atomisp_platform.h b/drivers/staging/media/atomisp/include/linux/atomisp_platform.h index 63dd7236e3a8..8060db0e0c5f 100644 --- a/drivers/staging/media/atomisp/include/linux/atomisp_platform.h +++ b/drivers/staging/media/atomisp/include/linux/atomisp_platform.h @@ -111,7 +111,6 @@ enum atomisp_input_format { enum intel_v4l2_subdev_type { RAW_CAMERA = 1, - LED_FLASH = 2, }; struct intel_v4l2_subdev_id { diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp_cmd.c index 38b7ebb186a5..472ce9e7ea71 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c +++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c @@ -61,14 +61,6 @@ #include "ia_css_debug.h" #include "bits.h" -/* We should never need to run the flash for more than 2 frames. - * At 15fps this means 133ms. We set the timeout a bit longer. - * Each flash driver is supposed to set its own timeout, but - * just in case someone else changed the timeout, we set it - * here to make sure we don't damage the flash hardware. - */ -#define FLASH_TIMEOUT 800 /* ms */ - union host { struct { void *kernel_ptr; @@ -677,7 +669,6 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, int error, struct atomisp_metadata_buf *md_buf = NULL, *_md_buf_tmp, *md_iter; enum atomisp_metadata_type md_type; struct atomisp_device *isp = asd->isp; - struct v4l2_control ctrl; int i, err; lockdep_assert_held(&isp->mutex); @@ -792,19 +783,6 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, int error, dev_dbg(isp->dev, "%s: vf frame with exp_id %d is ready\n", __func__, frame->exp_id); - if (asd->params.flash_state == ATOMISP_FLASH_ONGOING) { - if (frame->flash_state - == IA_CSS_FRAME_FLASH_STATE_PARTIAL) - dev_dbg(isp->dev, "%s thumb partially flashed\n", - __func__); - else if (frame->flash_state - == IA_CSS_FRAME_FLASH_STATE_FULL) - dev_dbg(isp->dev, "%s thumb completely flashed\n", - __func__); - else - dev_dbg(isp->dev, "%s thumb no flash in this frame\n", - __func__); - } pipe->frame_config_id[frame->vb.vb2_buf.index] = frame->isp_config_id; break; case IA_CSS_BUFFER_TYPE_OUTPUT_FRAME: @@ -835,40 +813,7 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, int error, } pipe->frame_config_id[i] = frame->isp_config_id; - ctrl.id = V4L2_CID_FLASH_MODE; - if (asd->params.flash_state == ATOMISP_FLASH_ONGOING) { - if (frame->flash_state == IA_CSS_FRAME_FLASH_STATE_PARTIAL) { - asd->frame_status[i] = ATOMISP_FRAME_STATUS_FLASH_PARTIAL; - dev_dbg(isp->dev, "%s partially flashed\n", __func__); - } else if (frame->flash_state == IA_CSS_FRAME_FLASH_STATE_FULL) { - asd->frame_status[i] = ATOMISP_FRAME_STATUS_FLASH_EXPOSED; - asd->params.num_flash_frames--; - dev_dbg(isp->dev, "%s completely flashed\n", __func__); - } else { - asd->frame_status[i] = ATOMISP_FRAME_STATUS_OK; - dev_dbg(isp->dev, "%s no flash in this frame\n", __func__); - } - - /* Check if flashing sequence is done */ - if (asd->frame_status[i] == ATOMISP_FRAME_STATUS_FLASH_EXPOSED) - asd->params.flash_state = ATOMISP_FLASH_DONE; - } else if (isp->flash) { - if (v4l2_g_ctrl(isp->flash->ctrl_handler, &ctrl) == 0 && - ctrl.value == ATOMISP_FLASH_MODE_TORCH) { - ctrl.id = V4L2_CID_FLASH_TORCH_INTENSITY; - if (v4l2_g_ctrl(isp->flash->ctrl_handler, &ctrl) == 0 && - ctrl.value > 0) - asd->frame_status[i] = ATOMISP_FRAME_STATUS_FLASH_EXPOSED; - else - asd->frame_status[i] = ATOMISP_FRAME_STATUS_OK; - } else { - asd->frame_status[i] = ATOMISP_FRAME_STATUS_OK; - } - } else { - asd->frame_status[i] = ATOMISP_FRAME_STATUS_OK; - } - - asd->params.last_frame_status = asd->frame_status[i]; + asd->frame_status[i] = ATOMISP_FRAME_STATUS_OK; if (asd->params.css_update_params_needed) { atomisp_apply_css_parameters(asd, @@ -1011,36 +956,6 @@ out_unlock: mutex_unlock(&isp->mutex); } -void atomisp_setup_flash(struct atomisp_sub_device *asd) -{ - struct atomisp_device *isp = asd->isp; - struct v4l2_control ctrl; - - if (!isp->flash) - return; - - if (asd->params.flash_state != ATOMISP_FLASH_REQUESTED && - asd->params.flash_state != ATOMISP_FLASH_DONE) - return; - - if (asd->params.num_flash_frames) { - /* make sure the timeout is set before setting flash mode */ - ctrl.id = V4L2_CID_FLASH_TIMEOUT; - ctrl.value = FLASH_TIMEOUT; - - if (v4l2_s_ctrl(NULL, isp->flash->ctrl_handler, &ctrl)) { - dev_err(isp->dev, "flash timeout configure failed\n"); - return; - } - - ia_css_stream_request_flash(asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream); - - asd->params.flash_state = ATOMISP_FLASH_ONGOING; - } else { - asd->params.flash_state = ATOMISP_FLASH_IDLE; - } -} - irqreturn_t atomisp_isr_thread(int irq, void *isp_ptr) { struct atomisp_device *isp = isp_ptr; @@ -1083,14 +998,8 @@ irqreturn_t atomisp_isr_thread(int irq, void *isp_ptr) * time, instead, dequue one and process one, then another */ mutex_lock(&isp->mutex); - if (atomisp_css_isr_thread(isp)) - goto out; - - if (isp->asd.streaming) - atomisp_setup_flash(&isp->asd); -out: + atomisp_css_isr_thread(isp); mutex_unlock(&isp->mutex); - dev_dbg(isp->dev, "<%s\n", __func__); return IRQ_HANDLED; } @@ -4581,28 +4490,6 @@ out: return ret; } -int atomisp_flash_enable(struct atomisp_sub_device *asd, int num_frames) -{ - struct atomisp_device *isp = asd->isp; - - if (num_frames < 0) { - dev_dbg(isp->dev, "%s ERROR: num_frames: %d\n", __func__, - num_frames); - return -EINVAL; - } - /* a requested flash is still in progress. */ - if (num_frames && asd->params.flash_state != ATOMISP_FLASH_IDLE) { - dev_dbg(isp->dev, "%s flash busy: %d frames left: %d\n", - __func__, asd->params.flash_state, - asd->params.num_flash_frames); - return -EBUSY; - } - - asd->params.num_flash_frames = num_frames; - asd->params.flash_state = ATOMISP_FLASH_REQUESTED; - return 0; -} - static int __checking_exp_id(struct atomisp_sub_device *asd, int exp_id) { struct atomisp_device *isp = asd->isp; diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.h b/drivers/staging/media/atomisp/pci/atomisp_cmd.h index 03703eed86fa..e69ca14645b9 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_cmd.h +++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.h @@ -58,7 +58,6 @@ void atomisp_clear_css_buffer_counters(struct atomisp_sub_device *asd); void atomisp_msi_irq_init(struct atomisp_device *isp); void atomisp_msi_irq_uninit(struct atomisp_device *isp); void atomisp_assert_recovery_work(struct work_struct *work); -void atomisp_setup_flash(struct atomisp_sub_device *asd); irqreturn_t atomisp_isr(int irq, void *dev); irqreturn_t atomisp_isr_thread(int irq, void *isp_ptr); const struct atomisp_format_bridge *get_atomisp_format_bridge_from_mbus( @@ -262,9 +261,6 @@ int atomisp_set_shading_table(struct atomisp_sub_device *asd, void atomisp_free_internal_buffers(struct atomisp_sub_device *asd); -int atomisp_flash_enable(struct atomisp_sub_device *asd, - int num_frames); - int atomisp_freq_scaling(struct atomisp_device *vdev, enum atomisp_dfs_mode mode, bool force); diff --git a/drivers/staging/media/atomisp/pci/atomisp_fops.c b/drivers/staging/media/atomisp/pci/atomisp_fops.c index b464a6bd0bad..0d0c1649eaad 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_fops.c +++ b/drivers/staging/media/atomisp/pci/atomisp_fops.c @@ -520,21 +520,12 @@ static int atomisp_open(struct file *file) } atomisp_dev_init_struct(isp); - - ret = v4l2_subdev_call(isp->flash, core, s_power, 1); - if (ret < 0 && ret != -ENODEV && ret != -ENOIOCTLCMD) { - dev_err(isp->dev, "Failed to power-on flash\n"); - goto css_error; - } - atomisp_subdev_init_struct(asd); pipe->users++; mutex_unlock(&isp->mutex); return 0; -css_error: - pm_runtime_put(vdev->v4l2_dev->dev); error: mutex_unlock(&isp->mutex); v4l2_fh_release(file); @@ -549,7 +540,6 @@ static int atomisp_release(struct file *file) struct atomisp_sub_device *asd = pipe->asd; struct v4l2_subdev_fh fh; struct v4l2_rect clear_compose = {0}; - int ret; v4l2_fh_init(&fh.vfh, vdev); @@ -584,10 +574,6 @@ static int atomisp_release(struct file *file) atomisp_destroy_pipes_stream(asd); - ret = v4l2_subdev_call(isp->flash, core, s_power, 0); - if (ret < 0 && ret != -ENODEV && ret != -ENOIOCTLCMD) - dev_warn(isp->dev, "Failed to power-off flash\n"); - if (pm_runtime_put_sync(vdev->v4l2_dev->dev) < 0) dev_err(isp->dev, "Failed to power off device\n"); diff --git a/drivers/staging/media/atomisp/pci/atomisp_internal.h b/drivers/staging/media/atomisp/pci/atomisp_internal.h index 54ab872b91ee..d021c26aacd7 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_internal.h +++ b/drivers/staging/media/atomisp/pci/atomisp_internal.h @@ -200,7 +200,6 @@ struct atomisp_device { struct v4l2_subdev *sensor_subdevs[ATOMISP_CAMERA_NR_PORTS]; unsigned int input_cnt; struct atomisp_input_subdev inputs[ATOM_ISP_MAX_INPUTS]; - struct v4l2_subdev *flash; struct atomisp_regs saved_regs; struct atomisp_css_env css_env; diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c index 8ef8cbc3b7a7..e243faec143e 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c +++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c @@ -136,15 +136,6 @@ static struct v4l2_queryctrl ci_v4l2_controls[] = { .step = 1, .default_value = 0, }, - { - .id = V4L2_CID_REQUEST_FLASH, - .type = V4L2_CTRL_TYPE_INTEGER, - .name = "Request flash frames", - .minimum = 0, - .maximum = 10, - .step = 1, - .default_value = 1, - }, { .id = V4L2_CID_ATOMISP_LOW_LIGHT, .type = V4L2_CTRL_TYPE_BOOLEAN, @@ -956,12 +947,6 @@ int atomisp_start_streaming(struct vb2_queue *vq, unsigned int count) atomisp_qbuffers_to_css(asd); - if (isp->flash) { - asd->params.num_flash_frames = 0; - asd->params.flash_state = ATOMISP_FLASH_IDLE; - atomisp_setup_flash(asd); - } - atomisp_css_irq_enable(isp, IA_CSS_IRQ_INFO_CSS_RECEIVER_SOF, atomisp_css_valid_sof(isp)); atomisp_csi2_configure(asd); @@ -1039,11 +1024,6 @@ void atomisp_stop_streaming(struct vb2_queue *vq) if (ret) dev_warn(isp->dev, "Stopping sensor stream failed: %d\n", ret); - if (isp->flash) { - asd->params.num_flash_frames = 0; - asd->params.flash_state = ATOMISP_FLASH_IDLE; - } - /* Disable the CSI interface on ANN B0/K0 */ if (isp->media_dev.hw_revision >= ((ATOMISP_HW_REVISION_ISP2401 << ATOMISP_HW_REVISION_SHIFT) | ATOMISP_HW_STEPPING_B0)) { @@ -1165,9 +1145,6 @@ static int atomisp_s_ctrl(struct file *file, void *fh, case V4L2_CID_ATOMISP_FALSE_COLOR_CORRECTION: ret = atomisp_false_color(asd, 1, &control->value); break; - case V4L2_CID_REQUEST_FLASH: - ret = atomisp_flash_enable(asd, control->value); - break; case V4L2_CID_ATOMISP_LOW_LIGHT: ret = atomisp_low_light(asd, 1, &control->value); break; @@ -1212,7 +1189,6 @@ static int atomisp_camera_g_ext_ctrls(struct file *file, void *fh, { struct video_device *vdev = video_devdata(file); struct atomisp_sub_device *asd = atomisp_to_video_pipe(vdev)->asd; - struct atomisp_device *isp = video_get_drvdata(vdev); struct v4l2_control ctrl; int i; int ret = 0; @@ -1221,19 +1197,6 @@ static int atomisp_camera_g_ext_ctrls(struct file *file, void *fh, ctrl.id = c->controls[i].id; ctrl.value = c->controls[i].value; switch (ctrl.id) { - case V4L2_CID_FLASH_STATUS: - case V4L2_CID_FLASH_INTENSITY: - case V4L2_CID_FLASH_TORCH_INTENSITY: - case V4L2_CID_FLASH_INDICATOR_INTENSITY: - case V4L2_CID_FLASH_TIMEOUT: - case V4L2_CID_FLASH_STROBE: - case V4L2_CID_FLASH_MODE: - case V4L2_CID_FLASH_STATUS_REGISTER: - if (isp->flash) - ret = - v4l2_g_ctrl(isp->flash->ctrl_handler, - &ctrl); - break; case V4L2_CID_ZOOM_ABSOLUTE: ret = atomisp_digital_zoom(asd, 0, &ctrl.value); break; @@ -1283,7 +1246,6 @@ static int atomisp_camera_s_ext_ctrls(struct file *file, void *fh, { struct video_device *vdev = video_devdata(file); struct atomisp_sub_device *asd = atomisp_to_video_pipe(vdev)->asd; - struct atomisp_device *isp = video_get_drvdata(vdev); struct v4l2_control ctrl; int i; int ret = 0; @@ -1294,29 +1256,6 @@ static int atomisp_camera_s_ext_ctrls(struct file *file, void *fh, ctrl.id = c->controls[i].id; ctrl.value = c->controls[i].value; switch (ctrl.id) { - case V4L2_CID_FLASH_STATUS: - case V4L2_CID_FLASH_INTENSITY: - case V4L2_CID_FLASH_TORCH_INTENSITY: - case V4L2_CID_FLASH_INDICATOR_INTENSITY: - case V4L2_CID_FLASH_TIMEOUT: - case V4L2_CID_FLASH_STROBE: - case V4L2_CID_FLASH_MODE: - case V4L2_CID_FLASH_STATUS_REGISTER: - if (isp->flash) { - ret = - v4l2_s_ctrl(NULL, isp->flash->ctrl_handler, - &ctrl); - /* - * When flash mode is changed we need to reset - * flash state - */ - if (ctrl.id == V4L2_CID_FLASH_MODE) { - asd->params.flash_state = - ATOMISP_FLASH_IDLE; - asd->params.num_flash_frames = 0; - } - } - break; case V4L2_CID_ZOOM_ABSOLUTE: ret = atomisp_digital_zoom(asd, 1, &ctrl.value); break; diff --git a/drivers/staging/media/atomisp/pci/atomisp_subdev.h b/drivers/staging/media/atomisp/pci/atomisp_subdev.h index bcfa829dbf61..4ab123a1c165 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_subdev.h +++ b/drivers/staging/media/atomisp/pci/atomisp_subdev.h @@ -108,14 +108,6 @@ struct atomisp_pad_format { struct v4l2_rect compose; }; -/* Internal states for flash process */ -enum atomisp_flash_state { - ATOMISP_FLASH_IDLE, - ATOMISP_FLASH_REQUESTED, - ATOMISP_FLASH_ONGOING, - ATOMISP_FLASH_DONE -}; - /* * This structure is used to cache the CSS parameters, it aligns to * struct ia_css_isp_config but without un-supported and deprecated parts. @@ -221,11 +213,6 @@ struct atomisp_subdev_params { int dvs_ver_proj_bytes; int dvs_hor_proj_bytes; - /* Flash */ - int num_flash_frames; - enum atomisp_flash_state flash_state; - enum atomisp_frame_status last_frame_status; - /* Flag to check if driver needs to update params to css */ bool css_update_params_needed; }; diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c index 0069b547754d..4c3d55301089 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c +++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c @@ -825,13 +825,6 @@ static int atomisp_subdev_probe(struct atomisp_device *isp) isp->sensor_lanes[mipi_port] = subdevs->lanes; isp->sensor_subdevs[subdevs->port] = subdevs->subdev; break; - case LED_FLASH: - if (isp->flash) { - dev_warn(isp->dev, "too many atomisp flash devices\n"); - continue; - } - isp->flash = subdevs->subdev; - break; default: dev_dbg(isp->dev, "unknown subdev probed\n"); break; diff --git a/drivers/staging/media/atomisp/pci/ia_css_frame_public.h b/drivers/staging/media/atomisp/pci/ia_css_frame_public.h index 7ba464abf447..a26d9598e400 100644 --- a/drivers/staging/media/atomisp/pci/ia_css_frame_public.h +++ b/drivers/staging/media/atomisp/pci/ia_css_frame_public.h @@ -137,12 +137,6 @@ enum ia_css_frame_delay { IA_CSS_FRAME_DELAY_2 /** Frame delay = 2 */ }; -enum ia_css_frame_flash_state { - IA_CSS_FRAME_FLASH_STATE_NONE, - IA_CSS_FRAME_FLASH_STATE_PARTIAL, - IA_CSS_FRAME_FLASH_STATE_FULL -}; - /* Frame structure. This structure describes an image buffer or frame. * This is the main structure used for all input and output images. */ @@ -176,7 +170,6 @@ struct ia_css_frame { * binary, we use output port, but we expect VF_OUTPUT_DONE event */ enum ia_css_buffer_type buf_type; - enum ia_css_frame_flash_state flash_state; unsigned int exp_id; /** exposure id, see ia_css_event_public.h for more detail */ u32 isp_config_id; /** Unique ID to track which config was actually applied to a particular frame */ @@ -202,7 +195,6 @@ struct ia_css_frame { .frame_info = IA_CSS_BINARY_DEFAULT_FRAME_INFO, \ .dynamic_queue_id = SH_CSS_INVALID_QUEUE_ID, \ .buf_type = IA_CSS_BUFFER_TYPE_INVALID, \ - .flash_state = IA_CSS_FRAME_FLASH_STATE_NONE, \ } /* @brief Allocate a CSS frame structure diff --git a/drivers/staging/media/atomisp/pci/ia_css_stream_public.h b/drivers/staging/media/atomisp/pci/ia_css_stream_public.h index 888f54d8495e..961c61288083 100644 --- a/drivers/staging/media/atomisp/pci/ia_css_stream_public.h +++ b/drivers/staging/media/atomisp/pci/ia_css_stream_public.h @@ -457,20 +457,6 @@ ia_css_stream_send_input_embedded_line(const struct ia_css_stream *stream, void ia_css_stream_end_input_frame(const struct ia_css_stream *stream); -/* @brief send a request flash command to SP - * - * @param[in] stream The stream. - * @return None - * - * Driver needs to call this function to send a flash request command - * to SP, SP will be responsible for switching on/off the flash at proper - * time. Due to the SP multi-threading environment, this request may have - * one-frame delay, the driver needs to check the flashed flag in frame info - * to determine which frame is being flashed. - */ -void -ia_css_stream_request_flash(struct ia_css_stream *stream); - /* @brief Configure a stream with filter coefficients. * @deprecated {Replaced by * ia_css_pipe_set_isp_config_on_pipe()} diff --git a/drivers/staging/media/atomisp/pci/sh_css.c b/drivers/staging/media/atomisp/pci/sh_css.c index 22c8cdcb2eb8..6520a35b6e47 100644 --- a/drivers/staging/media/atomisp/pci/sh_css.c +++ b/drivers/staging/media/atomisp/pci/sh_css.c @@ -2834,7 +2834,6 @@ init_vf_frameinfo_defaults(struct ia_css_pipe *pipe, assert(vf_frame); sh_css_pipe_get_viewfinder_frame_info(pipe, &vf_frame->frame_info, idx); - vf_frame->flash_state = IA_CSS_FRAME_FLASH_STATE_NONE; ia_css_pipeline_get_sp_thread_id(ia_css_pipe_get_pipe_num(pipe), &thread_id); ia_css_query_internal_queue_id(IA_CSS_BUFFER_TYPE_VF_OUTPUT_FRAME + idx, thread_id, &queue_id); vf_frame->dynamic_queue_id = queue_id; @@ -3012,7 +3011,6 @@ init_in_frameinfo_memory_defaults(struct ia_css_pipe *pipe, in_frame->frame_info.raw_bit_depth = ia_css_pipe_util_pipe_input_format_bpp(pipe); ia_css_frame_info_set_width(&in_frame->frame_info, pipe->stream->config.input_config.input_res.width, 0); - in_frame->flash_state = IA_CSS_FRAME_FLASH_STATE_NONE; ia_css_pipeline_get_sp_thread_id(ia_css_pipe_get_pipe_num(pipe), &thread_id); ia_css_query_internal_queue_id(IA_CSS_BUFFER_TYPE_INPUT_FRAME, thread_id, &queue_id); in_frame->dynamic_queue_id = queue_id; @@ -3040,7 +3038,6 @@ init_out_frameinfo_defaults(struct ia_css_pipe *pipe, assert(out_frame); sh_css_pipe_get_output_frame_info(pipe, &out_frame->frame_info, idx); - out_frame->flash_state = IA_CSS_FRAME_FLASH_STATE_NONE; ia_css_pipeline_get_sp_thread_id(ia_css_pipe_get_pipe_num(pipe), &thread_id); ia_css_query_internal_queue_id(IA_CSS_BUFFER_TYPE_OUTPUT_FRAME + idx, thread_id, &queue_id); out_frame->dynamic_queue_id = queue_id; @@ -3821,12 +3818,6 @@ ia_css_pipe_dequeue_buffer(struct ia_css_pipe *pipe, buffer->exp_id = ddr_buffer.payload.frame.exp_id; frame->exp_id = ddr_buffer.payload.frame.exp_id; frame->isp_config_id = ddr_buffer.payload.frame.isp_parameters_id; - if (ddr_buffer.payload.frame.flashed == 1) - frame->flash_state = - IA_CSS_FRAME_FLASH_STATE_PARTIAL; - if (ddr_buffer.payload.frame.flashed == 2) - frame->flash_state = - IA_CSS_FRAME_FLASH_STATE_FULL; frame->valid = pipe->num_invalid_frames == 0; if (!frame->valid) pipe->num_invalid_frames--; @@ -6788,8 +6779,6 @@ create_host_copy_pipeline(struct ia_css_pipe *pipe, ia_css_pipeline_clean(me); /* Construct out_frame info */ - out_frame->flash_state = IA_CSS_FRAME_FLASH_STATE_NONE; - if (copy_on_sp(pipe) && pipe->stream->config.input_config.format == ATOMISP_INPUT_FORMAT_BINARY_8) { ia_css_frame_info_init(&out_frame->frame_info, JPEG_BYTES, 1, @@ -6837,7 +6826,6 @@ create_host_isyscopy_capture_pipeline(struct ia_css_pipe *pipe) err = sh_css_pipe_get_output_frame_info(pipe, &out_frame->frame_info, 0); if (err) return err; - out_frame->flash_state = IA_CSS_FRAME_FLASH_STATE_NONE; ia_css_pipeline_get_sp_thread_id(ia_css_pipe_get_pipe_num(pipe), &thread_id); ia_css_query_internal_queue_id(IA_CSS_BUFFER_TYPE_OUTPUT_FRAME, thread_id, &queue_id); out_frame->dynamic_queue_id = queue_id; @@ -7492,27 +7480,6 @@ int ia_css_stream_capture(struct ia_css_stream *stream, int num_captures, return return_err; } -void ia_css_stream_request_flash(struct ia_css_stream *stream) -{ - (void)stream; - - assert(stream); - ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, - "ia_css_stream_request_flash() enter: void\n"); - - if (!IS_ISP2401 || sh_css_sp_is_running()) { - if (!sh_css_write_host2sp_command(host2sp_cmd_start_flash) && IS_ISP2401) { - IA_CSS_ERROR("Call to 'sh-css_write_host2sp_command()' failed"); - ia_css_debug_dump_sp_sw_debug_info(); - } - } else { - IA_CSS_LOG("SP is not running!"); - } - - ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, - "ia_css_stream_request_flash() leave: return_void\n"); -} - static void sh_css_init_host_sp_control_vars(void) { -- cgit v1.2.3 From 659a66995fc75e0a945c8999574e0d358a3889fd Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sat, 13 Apr 2024 16:14:52 +0100 Subject: media: atomisp: Drop unused frame_status tracking After removing the flash support frame_status now always is ATOMISP_FRAME_STATUS_OK aka 0. Drop frame_status tracking. This also means one less atomisp custom use for the vb2_buffer->reserved* fields (all custom use of these fields should be removed). While at it also remove the no longer used vf_frame pointer from struct atomisp_sub_device. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/include/linux/atomisp.h | 15 --------------- drivers/staging/media/atomisp/pci/atomisp_cmd.c | 1 - drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 12 ++---------- drivers/staging/media/atomisp/pci/atomisp_subdev.h | 3 --- 4 files changed, 2 insertions(+), 29 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/include/linux/atomisp.h b/drivers/staging/media/atomisp/include/linux/atomisp.h index db0c1b87c9ef..16c9da172c03 100644 --- a/drivers/staging/media/atomisp/include/linux/atomisp.h +++ b/drivers/staging/media/atomisp/include/linux/atomisp.h @@ -614,21 +614,6 @@ enum atomisp_camera_port { ATOMISP_CAMERA_NR_PORTS }; -/* Frame status. This is used to detect corrupted frames and flash - * exposed frames. Usually, the first 2 frames coming out of the sensor - * are corrupted. When using flash, the frame before and the frame after - * the flash exposed frame may be partially exposed by flash. The ISP - * statistics for these frames should not be used by the 3A library. - * The frame status value can be found in the "reserved" field in the - * v4l2_buffer struct. */ -enum atomisp_frame_status { - ATOMISP_FRAME_STATUS_OK, - ATOMISP_FRAME_STATUS_CORRUPTED, - ATOMISP_FRAME_STATUS_FLASH_EXPOSED, - ATOMISP_FRAME_STATUS_FLASH_PARTIAL, - ATOMISP_FRAME_STATUS_FLASH_FAILED, -}; - enum atomisp_ext_isp_id { EXT_ISP_CID_ISO = 0, EXT_ISP_CID_CAPTURE_HDR, diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp_cmd.c index 472ce9e7ea71..9fc2f0af6f3d 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c +++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c @@ -813,7 +813,6 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, int error, } pipe->frame_config_id[i] = frame->isp_config_id; - asd->frame_status[i] = ATOMISP_FRAME_STATUS_OK; if (asd->params.css_update_params_needed) { atomisp_apply_css_parameters(asd, diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c index e243faec143e..d7c842997139 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c +++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c @@ -826,7 +826,6 @@ static int atomisp_dqbuf_wrapper(struct file *file, void *fh, struct v4l2_buffer { struct video_device *vdev = video_devdata(file); struct atomisp_video_pipe *pipe = atomisp_to_video_pipe(vdev); - struct atomisp_sub_device *asd = pipe->asd; struct atomisp_device *isp = video_get_drvdata(vdev); struct ia_css_frame *frame; struct vb2_buffer *vb; @@ -839,15 +838,8 @@ static int atomisp_dqbuf_wrapper(struct file *file, void *fh, struct v4l2_buffer vb = vb2_get_buffer(&pipe->vb_queue, buf->index); frame = vb_to_frame(vb); - buf->reserved = asd->frame_status[buf->index]; - - /* - * Hack: - * Currently frame_status in the enum type which takes no more lower - * 8 bit. - * use bit[31:16] for exp_id as it is only in the range of 1~255 - */ - buf->reserved &= 0x0000ffff; + /* reserved bit[31:16] is used for exp_id */ + buf->reserved = 0; if (!(buf->flags & V4L2_BUF_FLAG_ERROR)) buf->reserved |= frame->exp_id; buf->reserved2 = pipe->frame_config_id[buf->index]; diff --git a/drivers/staging/media/atomisp/pci/atomisp_subdev.h b/drivers/staging/media/atomisp/pci/atomisp_subdev.h index 4ab123a1c165..b6c66a5d523c 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_subdev.h +++ b/drivers/staging/media/atomisp/pci/atomisp_subdev.h @@ -274,9 +274,6 @@ struct atomisp_sub_device { struct list_head dis_stats_in_css; spinlock_t dis_stats_lock; - struct ia_css_frame *vf_frame; /* TODO: needed? */ - enum atomisp_frame_status frame_status[VIDEO_MAX_FRAME]; - /* This field specifies which camera (v4l2 input) is selected. */ int input_curr; -- cgit v1.2.3 From e838b8c69e45bbb00bd2a861d8fbb94d4d933b22 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 14 Apr 2024 15:25:38 +0100 Subject: media: atomisp: Drop intel_v4l2_subdev_type intel_v4l2_subdev_type / atomisp_input_subdev.type now always is RAW_CAMERA, drop it. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/i2c/atomisp-gc2235.c | 2 +- .../staging/media/atomisp/i2c/atomisp-mt9m114.c | 2 +- drivers/staging/media/atomisp/i2c/atomisp-ov2722.c | 2 +- .../atomisp/include/linux/atomisp_gmin_platform.h | 3 +- .../media/atomisp/include/linux/atomisp_platform.h | 11 ------- .../media/atomisp/pci/atomisp_gmin_platform.c | 16 ++++------ .../staging/media/atomisp/pci/atomisp_internal.h | 1 - drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 1 - drivers/staging/media/atomisp/pci/atomisp_v4l2.c | 34 +++++++++------------- 9 files changed, 22 insertions(+), 50 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/i2c/atomisp-gc2235.c b/drivers/staging/media/atomisp/i2c/atomisp-gc2235.c index bec4c5615864..994b8bceb4f5 100644 --- a/drivers/staging/media/atomisp/i2c/atomisp-gc2235.c +++ b/drivers/staging/media/atomisp/i2c/atomisp-gc2235.c @@ -852,7 +852,7 @@ static int gc2235_probe(struct i2c_client *client) if (ret) gc2235_remove(client); - return atomisp_register_i2c_module(&dev->sd, gcpdev, RAW_CAMERA); + return atomisp_register_i2c_module(&dev->sd, gcpdev); out_free: v4l2_device_unregister_subdev(&dev->sd); diff --git a/drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c b/drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c index 20f02d18a8de..03ebee976d5b 100644 --- a/drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c +++ b/drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c @@ -1552,7 +1552,7 @@ static int mt9m114_probe(struct i2c_client *client) return ret; } - ret = atomisp_register_i2c_module(&dev->sd, pdata, RAW_CAMERA); + ret = atomisp_register_i2c_module(&dev->sd, pdata); if (ret) { v4l2_device_unregister_subdev(&dev->sd); kfree(dev); diff --git a/drivers/staging/media/atomisp/i2c/atomisp-ov2722.c b/drivers/staging/media/atomisp/i2c/atomisp-ov2722.c index d60630ea16df..c31a81d64950 100644 --- a/drivers/staging/media/atomisp/i2c/atomisp-ov2722.c +++ b/drivers/staging/media/atomisp/i2c/atomisp-ov2722.c @@ -992,7 +992,7 @@ static int ov2722_probe(struct i2c_client *client) if (ret) ov2722_remove(client); - return atomisp_register_i2c_module(&dev->sd, ovpdev, RAW_CAMERA); + return atomisp_register_i2c_module(&dev->sd, ovpdev); out_ctrl_handler_free: v4l2_ctrl_handler_free(&dev->ctrl_handler); diff --git a/drivers/staging/media/atomisp/include/linux/atomisp_gmin_platform.h b/drivers/staging/media/atomisp/include/linux/atomisp_gmin_platform.h index 64bd54835c32..711e8fb3464f 100644 --- a/drivers/staging/media/atomisp/include/linux/atomisp_gmin_platform.h +++ b/drivers/staging/media/atomisp/include/linux/atomisp_gmin_platform.h @@ -19,8 +19,7 @@ #include "atomisp_platform.h" int atomisp_register_i2c_module(struct v4l2_subdev *subdev, - struct camera_sensor_platform_data *plat_data, - enum intel_v4l2_subdev_type type); + struct camera_sensor_platform_data *plat_data); int atomisp_gmin_remove_subdev(struct v4l2_subdev *sd); int gmin_get_var_int(struct device *dev, bool is_gmin, const char *var, int def); diff --git a/drivers/staging/media/atomisp/include/linux/atomisp_platform.h b/drivers/staging/media/atomisp/include/linux/atomisp_platform.h index 8060db0e0c5f..51e7b199e005 100644 --- a/drivers/staging/media/atomisp/include/linux/atomisp_platform.h +++ b/drivers/staging/media/atomisp/include/linux/atomisp_platform.h @@ -109,18 +109,7 @@ enum atomisp_input_format { #define N_ATOMISP_INPUT_FORMAT (ATOMISP_INPUT_FORMAT_USER_DEF8 + 1) -enum intel_v4l2_subdev_type { - RAW_CAMERA = 1, -}; - -struct intel_v4l2_subdev_id { - char name[17]; - enum intel_v4l2_subdev_type type; - enum atomisp_camera_port port; -}; - struct intel_v4l2_subdev_table { - enum intel_v4l2_subdev_type type; enum atomisp_camera_port port; unsigned int lanes; struct v4l2_subdev *subdev; diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c index a5e68b2cac50..aba69cf97785 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c @@ -126,7 +126,7 @@ static DEFINE_MUTEX(gmin_regulator_mutex); static int gmin_v1p8_enable_count; static int gmin_v2p8_enable_count; -/* The atomisp uses type==0 for the end-of-list marker, so leave space. */ +/* The atomisp uses subdev==NULL for the end-of-list marker, so leave space. */ static struct intel_v4l2_subdev_table pdata_subdevs[MAX_SUBDEVS + 1]; static const struct atomisp_platform_data pdata = { @@ -145,16 +145,13 @@ const struct atomisp_platform_data *atomisp_get_platform_data(void) EXPORT_SYMBOL_GPL(atomisp_get_platform_data); int atomisp_register_i2c_module(struct v4l2_subdev *subdev, - struct camera_sensor_platform_data *plat_data, - enum intel_v4l2_subdev_type type) + struct camera_sensor_platform_data *plat_data) { int i; struct gmin_subdev *gs; struct i2c_client *client = v4l2_get_subdevdata(subdev); struct acpi_device *adev = ACPI_COMPANION(&client->dev); - dev_info(&client->dev, "register atomisp i2c module type %d\n", type); - /* The windows driver model (and thus most BIOSes by default) * uses ACPI runtime power management for camera devices, but * we don't. Disable it, or else the rails will be needlessly @@ -172,10 +169,10 @@ int atomisp_register_i2c_module(struct v4l2_subdev *subdev, adev->power.flags.power_resources = 0; for (i = 0; i < MAX_SUBDEVS; i++) - if (!pdata.subdevs[i].type) + if (!pdata.subdevs[i].subdev) break; - if (pdata.subdevs[i].type) + if (i == MAX_SUBDEVS) return -ENOMEM; /* Note subtlety of initialization order: at the point where @@ -187,7 +184,6 @@ int atomisp_register_i2c_module(struct v4l2_subdev *subdev, if (!gs) return -ENODEV; - pdata.subdevs[i].type = type; pdata.subdevs[i].port = gs->csi_port; pdata.subdevs[i].lanes = gs->csi_lanes; pdata.subdevs[i].subdev = subdev; @@ -1136,7 +1132,7 @@ int atomisp_register_sensor_no_gmin(struct v4l2_subdev *subdev, u32 lanes, } for (i = 0; i < MAX_SUBDEVS; i++) - if (!pdata.subdevs[i].type) + if (!pdata.subdevs[i].subdev) break; if (i >= MAX_SUBDEVS) { @@ -1148,7 +1144,6 @@ int atomisp_register_sensor_no_gmin(struct v4l2_subdev *subdev, u32 lanes, if (ret) return ret; - pdata.subdevs[i].type = RAW_CAMERA; pdata.subdevs[i].port = port; pdata.subdevs[i].lanes = lanes; pdata.subdevs[i].subdev = subdev; @@ -1166,7 +1161,6 @@ void atomisp_unregister_subdev(struct v4l2_subdev *subdev) camera_sensor_csi_free(subdev); pdata.subdevs[i].subdev = NULL; - pdata.subdevs[i].type = 0; pdata.subdevs[i].port = 0; break; } diff --git a/drivers/staging/media/atomisp/pci/atomisp_internal.h b/drivers/staging/media/atomisp/pci/atomisp_internal.h index d021c26aacd7..9227399502b9 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_internal.h +++ b/drivers/staging/media/atomisp/pci/atomisp_internal.h @@ -121,7 +121,6 @@ round_down((2 * (n) + (d) * (step)) / (2 * (d)), (step)) struct atomisp_input_subdev { - unsigned int type; enum atomisp_camera_port port; u32 code; /* MEDIA_BUS_FMT_* */ bool binning_support; diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c index d7c842997139..effc71b5a439 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c +++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c @@ -406,7 +406,6 @@ static int atomisp_enum_input(struct file *file, void *fh, input->type = V4L2_INPUT_TYPE_CAMERA; input->index = index; - input->reserved[0] = isp->inputs[index].type; input->reserved[1] = isp->inputs[index].port; return 0; diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c index 4c3d55301089..013c5abfe1ea 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c +++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c @@ -803,32 +803,25 @@ static int atomisp_subdev_probe(struct atomisp_device *isp) * converting them to standard v4l2 sensor drivers using runtime-pm + * ACPI for pm and v4l2_async_register_subdev_sensor() registration. */ - for (subdevs = pdata->subdevs; subdevs->type; ++subdevs) { + for (subdevs = pdata->subdevs; subdevs->subdev; subdevs++) { ret = v4l2_device_register_subdev(&isp->v4l2_dev, subdevs->subdev); if (ret) continue; - switch (subdevs->type) { - case RAW_CAMERA: - if (subdevs->port >= ATOMISP_CAMERA_NR_PORTS) { - dev_err(isp->dev, "port %d not supported\n", subdevs->port); - break; - } - - if (isp->sensor_subdevs[subdevs->port]) { - dev_err(isp->dev, "port %d already has a sensor attached\n", - subdevs->port); - break; - } + if (subdevs->port >= ATOMISP_CAMERA_NR_PORTS) { + dev_err(isp->dev, "port %d not supported\n", subdevs->port); + continue; + } - mipi_port = atomisp_port_to_mipi_port(isp, subdevs->port); - isp->sensor_lanes[mipi_port] = subdevs->lanes; - isp->sensor_subdevs[subdevs->port] = subdevs->subdev; - break; - default: - dev_dbg(isp->dev, "unknown subdev probed\n"); - break; + if (isp->sensor_subdevs[subdevs->port]) { + dev_err(isp->dev, "port %d already has a sensor attached\n", + subdevs->port); + continue; } + + mipi_port = atomisp_port_to_mipi_port(isp, subdevs->port); + isp->sensor_lanes[mipi_port] = subdevs->lanes; + isp->sensor_subdevs[subdevs->port] = subdevs->subdev; } return atomisp_csi_lane_config(isp); @@ -1039,7 +1032,6 @@ int atomisp_register_device_nodes(struct atomisp_device *isp) input = &isp->inputs[isp->input_cnt]; - input->type = RAW_CAMERA; input->port = i; input->camera = isp->sensor_subdevs[i]; input->csi_port = &isp->csi2_port[i].subdev; -- cgit v1.2.3 From 74350ed0787e82cc6af5b7cd1d4d4cc1db5b29d4 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 14 Apr 2024 14:57:43 +0100 Subject: media: atomisp: Remove gmin_platform VCM code. VCM support has already been removed from the main atomisp driver in commit 7473c97dd8d0 ("media: atomisp: Remove custom VCM handling") remove the left-over dead VCM handling from the gmin platform code. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- .../atomisp/include/linux/atomisp_gmin_platform.h | 3 -- .../media/atomisp/include/linux/atomisp_platform.h | 21 ---------- .../media/atomisp/pci/atomisp_gmin_platform.c | 47 ---------------------- 3 files changed, 71 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/include/linux/atomisp_gmin_platform.h b/drivers/staging/media/atomisp/include/linux/atomisp_gmin_platform.h index 711e8fb3464f..ecd82220f04a 100644 --- a/drivers/staging/media/atomisp/include/linux/atomisp_gmin_platform.h +++ b/drivers/staging/media/atomisp/include/linux/atomisp_gmin_platform.h @@ -28,7 +28,4 @@ gmin_camera_platform_data( struct v4l2_subdev *subdev, enum atomisp_input_format csi_format, enum atomisp_bayer_order csi_bayer); - -int atomisp_gmin_register_vcm_control(struct camera_vcm_control *); - #endif diff --git a/drivers/staging/media/atomisp/include/linux/atomisp_platform.h b/drivers/staging/media/atomisp/include/linux/atomisp_platform.h index 51e7b199e005..098859bde86f 100644 --- a/drivers/staging/media/atomisp/include/linux/atomisp_platform.h +++ b/drivers/staging/media/atomisp/include/linux/atomisp_platform.h @@ -147,25 +147,6 @@ struct atomisp_input_stream_info { struct atomisp_isys_config_info isys_info[MAX_STREAMS_PER_CHANNEL]; }; -struct camera_vcm_control; -struct camera_vcm_ops { - int (*power_up)(struct v4l2_subdev *sd, struct camera_vcm_control *vcm); - int (*power_down)(struct v4l2_subdev *sd, - struct camera_vcm_control *vcm); - int (*queryctrl)(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc, - struct camera_vcm_control *vcm); - int (*g_ctrl)(struct v4l2_subdev *sd, struct v4l2_control *ctrl, - struct camera_vcm_control *vcm); - int (*s_ctrl)(struct v4l2_subdev *sd, struct v4l2_control *ctrl, - struct camera_vcm_control *vcm); -}; - -struct camera_vcm_control { - char camera_module[CAMERA_MODULE_ID_LEN]; - struct camera_vcm_ops *ops; - struct list_head list; -}; - struct camera_sensor_platform_data { int (*flisclk_ctrl)(struct v4l2_subdev *subdev, int flag); int (*csi_cfg)(struct v4l2_subdev *subdev, int flag); @@ -179,8 +160,6 @@ struct camera_sensor_platform_data { int (*v1p8_ctrl)(struct v4l2_subdev *subdev, int on); int (*v2p8_ctrl)(struct v4l2_subdev *subdev, int on); int (*v1p2_ctrl)(struct v4l2_subdev *subdev, int on); - struct camera_vcm_control *(*get_vcm_ctrl)(struct v4l2_subdev *subdev, - char *module_id); }; struct camera_mipi_info { diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c index aba69cf97785..e12354820a3a 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c @@ -75,7 +75,6 @@ struct gmin_subdev { struct regulator *v1p8_reg; struct regulator *v2p8_reg; struct regulator *v1p2_reg; - struct regulator *v2p8_vcm_reg; enum atomisp_camera_port csi_port; unsigned int csi_lanes; enum atomisp_input_format csi_fmt; @@ -85,7 +84,6 @@ struct gmin_subdev { bool v1p8_on; bool v2p8_on; bool v1p2_on; - bool v2p8_vcm_on; int v1p8_gpio; int v2p8_gpio; @@ -133,9 +131,6 @@ static const struct atomisp_platform_data pdata = { .subdevs = pdata_subdevs, }; -static LIST_HEAD(vcm_devices); -static DEFINE_MUTEX(vcm_lock); - static struct gmin_subdev *find_gmin_subdev(struct v4l2_subdev *subdev); const struct atomisp_platform_data *atomisp_get_platform_data(void) @@ -214,7 +209,6 @@ int atomisp_gmin_remove_subdev(struct v4l2_subdev *sd) regulator_put(gmin_subdevs[i].v1p8_reg); regulator_put(gmin_subdevs[i].v2p8_reg); regulator_put(gmin_subdevs[i].v1p2_reg); - regulator_put(gmin_subdevs[i].v2p8_vcm_reg); } gmin_subdevs[i].subdev = NULL; } @@ -664,7 +658,6 @@ static int gmin_subdev_add(struct gmin_subdev *gs) gs->v2p8_reg = regulator_get(dev, "V2P8SX"); gs->v1p2_reg = regulator_get(dev, "V1P2A"); - gs->v2p8_vcm_reg = regulator_get(dev, "VPROG4B"); /* Note: ideally we would initialize v[12]p8_on to the * output of regulator_is_enabled(), but sadly that @@ -1167,31 +1160,6 @@ void atomisp_unregister_subdev(struct v4l2_subdev *subdev) } EXPORT_SYMBOL_GPL(atomisp_unregister_subdev); -static struct camera_vcm_control *gmin_get_vcm_ctrl(struct v4l2_subdev *subdev, - char *camera_module) -{ - struct i2c_client *client = v4l2_get_subdevdata(subdev); - struct gmin_subdev *gs = find_gmin_subdev(subdev); - struct camera_vcm_control *vcm; - - if (!client || !gs) - return NULL; - - if (!camera_module) - return NULL; - - mutex_lock(&vcm_lock); - list_for_each_entry(vcm, &vcm_devices, list) { - if (!strcmp(camera_module, vcm->camera_module)) { - mutex_unlock(&vcm_lock); - return vcm; - } - } - - mutex_unlock(&vcm_lock); - return NULL; -} - static struct camera_sensor_platform_data pmic_gmin_plat = { .gpio0_ctrl = gmin_gpio0_ctrl, .gpio1_ctrl = gmin_gpio1_ctrl, @@ -1200,7 +1168,6 @@ static struct camera_sensor_platform_data pmic_gmin_plat = { .v1p2_ctrl = gmin_v1p2_ctrl, .flisclk_ctrl = gmin_flisclk_ctrl, .csi_cfg = gmin_csi_cfg, - .get_vcm_ctrl = gmin_get_vcm_ctrl, }; static struct camera_sensor_platform_data acpi_gmin_plat = { @@ -1211,7 +1178,6 @@ static struct camera_sensor_platform_data acpi_gmin_plat = { .v1p2_ctrl = gmin_acpi_pm_ctrl, .flisclk_ctrl = gmin_acpi_pm_ctrl, .csi_cfg = gmin_csi_cfg, - .get_vcm_ctrl = gmin_get_vcm_ctrl, }; struct camera_sensor_platform_data * @@ -1236,19 +1202,6 @@ gmin_camera_platform_data(struct v4l2_subdev *subdev, } EXPORT_SYMBOL_GPL(gmin_camera_platform_data); -int atomisp_gmin_register_vcm_control(struct camera_vcm_control *vcmCtrl) -{ - if (!vcmCtrl) - return -EINVAL; - - mutex_lock(&vcm_lock); - list_add_tail(&vcmCtrl->list, &vcm_devices); - mutex_unlock(&vcm_lock); - - return 0; -} -EXPORT_SYMBOL_GPL(atomisp_gmin_register_vcm_control); - static int gmin_get_hardcoded_var(struct device *dev, struct gmin_cfg_var *varlist, const char *var8, char *out, size_t *out_len) -- cgit v1.2.3 From 0445126fcaad0e13e6bc7a788c9ddb4e75739f59 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 14 Apr 2024 15:31:26 +0100 Subject: media: atomisp: Remove struct atomisp_platform_data struct atomisp_platform_data only has a single subdevs member. Remove this struct and replace atomisp_get_platform_data() with atomisp_platform_get_subdevs(). Note atomisp_get_platform_data() and now atomisp_platform_get_subdevs() always succeed, so while at it also remove unnecessary error checking. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- .../media/atomisp/include/linux/atomisp_platform.h | 6 +--- .../media/atomisp/pci/atomisp_gmin_platform.c | 36 ++++++++++------------ .../staging/media/atomisp/pci/atomisp_internal.h | 1 - drivers/staging/media/atomisp/pci/atomisp_v4l2.c | 16 ++-------- 4 files changed, 19 insertions(+), 40 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/include/linux/atomisp_platform.h b/drivers/staging/media/atomisp/include/linux/atomisp_platform.h index 098859bde86f..0e3f6fb78483 100644 --- a/drivers/staging/media/atomisp/include/linux/atomisp_platform.h +++ b/drivers/staging/media/atomisp/include/linux/atomisp_platform.h @@ -115,10 +115,6 @@ struct intel_v4l2_subdev_table { struct v4l2_subdev *subdev; }; -struct atomisp_platform_data { - struct intel_v4l2_subdev_table *subdevs; -}; - /* * Sensor of external ISP can send multiple steams with different mipi data * type in the same virtual channel. This information needs to come from the @@ -173,7 +169,7 @@ struct camera_mipi_info { const u32 *metadata_effective_width; }; -const struct atomisp_platform_data *atomisp_get_platform_data(void); +const struct intel_v4l2_subdev_table *atomisp_platform_get_subdevs(void); int atomisp_register_sensor_no_gmin(struct v4l2_subdev *subdev, u32 lanes, enum atomisp_input_format format, enum atomisp_bayer_order bayer_order); diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c index e12354820a3a..e176483df301 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c @@ -127,17 +127,13 @@ static int gmin_v2p8_enable_count; /* The atomisp uses subdev==NULL for the end-of-list marker, so leave space. */ static struct intel_v4l2_subdev_table pdata_subdevs[MAX_SUBDEVS + 1]; -static const struct atomisp_platform_data pdata = { - .subdevs = pdata_subdevs, -}; - static struct gmin_subdev *find_gmin_subdev(struct v4l2_subdev *subdev); -const struct atomisp_platform_data *atomisp_get_platform_data(void) +const struct intel_v4l2_subdev_table *atomisp_platform_get_subdevs(void) { - return &pdata; + return pdata_subdevs; } -EXPORT_SYMBOL_GPL(atomisp_get_platform_data); +EXPORT_SYMBOL_GPL(atomisp_platform_get_subdevs); int atomisp_register_i2c_module(struct v4l2_subdev *subdev, struct camera_sensor_platform_data *plat_data) @@ -164,7 +160,7 @@ int atomisp_register_i2c_module(struct v4l2_subdev *subdev, adev->power.flags.power_resources = 0; for (i = 0; i < MAX_SUBDEVS; i++) - if (!pdata.subdevs[i].subdev) + if (!pdata_subdevs[i].subdev) break; if (i == MAX_SUBDEVS) @@ -179,9 +175,9 @@ int atomisp_register_i2c_module(struct v4l2_subdev *subdev, if (!gs) return -ENODEV; - pdata.subdevs[i].port = gs->csi_port; - pdata.subdevs[i].lanes = gs->csi_lanes; - pdata.subdevs[i].subdev = subdev; + pdata_subdevs[i].port = gs->csi_port; + pdata_subdevs[i].lanes = gs->csi_lanes; + pdata_subdevs[i].subdev = subdev; return 0; } EXPORT_SYMBOL_GPL(atomisp_register_i2c_module); @@ -194,9 +190,9 @@ int atomisp_gmin_remove_subdev(struct v4l2_subdev *sd) return 0; for (i = 0; i < MAX_SUBDEVS; i++) { - if (pdata.subdevs[i].subdev == sd) { + if (pdata_subdevs[i].subdev == sd) { for (j = i + 1; j <= MAX_SUBDEVS; j++) - pdata.subdevs[j - 1] = pdata.subdevs[j]; + pdata_subdevs[j - 1] = pdata_subdevs[j]; } if (gmin_subdevs[i].subdev == sd) { if (gmin_subdevs[i].gpio0) @@ -1125,7 +1121,7 @@ int atomisp_register_sensor_no_gmin(struct v4l2_subdev *subdev, u32 lanes, } for (i = 0; i < MAX_SUBDEVS; i++) - if (!pdata.subdevs[i].subdev) + if (!pdata_subdevs[i].subdev) break; if (i >= MAX_SUBDEVS) { @@ -1137,9 +1133,9 @@ int atomisp_register_sensor_no_gmin(struct v4l2_subdev *subdev, u32 lanes, if (ret) return ret; - pdata.subdevs[i].port = port; - pdata.subdevs[i].lanes = lanes; - pdata.subdevs[i].subdev = subdev; + pdata_subdevs[i].port = port; + pdata_subdevs[i].lanes = lanes; + pdata_subdevs[i].subdev = subdev; return 0; } EXPORT_SYMBOL_GPL(atomisp_register_sensor_no_gmin); @@ -1149,12 +1145,12 @@ void atomisp_unregister_subdev(struct v4l2_subdev *subdev) int i; for (i = 0; i < MAX_SUBDEVS; i++) { - if (pdata.subdevs[i].subdev != subdev) + if (pdata_subdevs[i].subdev != subdev) continue; camera_sensor_csi_free(subdev); - pdata.subdevs[i].subdev = NULL; - pdata.subdevs[i].port = 0; + pdata_subdevs[i].subdev = NULL; + pdata_subdevs[i].port = 0; break; } } diff --git a/drivers/staging/media/atomisp/pci/atomisp_internal.h b/drivers/staging/media/atomisp/pci/atomisp_internal.h index 9227399502b9..9c2bc5332fa4 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_internal.h +++ b/drivers/staging/media/atomisp/pci/atomisp_internal.h @@ -175,7 +175,6 @@ struct atomisp_device { struct media_device media_dev; struct atomisp_sub_device asd; struct v4l2_async_notifier notifier; - struct atomisp_platform_data *pdata; void *mmu_l1_base; void __iomem *base; const struct firmware *firmware; diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c index 013c5abfe1ea..9df0eb7044b7 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c +++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c @@ -783,27 +783,20 @@ int atomisp_csi_lane_config(struct atomisp_device *isp) static int atomisp_subdev_probe(struct atomisp_device *isp) { - const struct atomisp_platform_data *pdata; - struct intel_v4l2_subdev_table *subdevs; + const struct intel_v4l2_subdev_table *subdevs; int ret, mipi_port; ret = atomisp_csi2_bridge_parse_firmware(isp); if (ret) return ret; - pdata = atomisp_get_platform_data(); - if (!pdata) { - dev_err(isp->dev, "no platform data available\n"); - return 0; - } - /* * TODO: this is left here for now to allow testing atomisp-sensor * drivers which are still using the atomisp_gmin_platform infra before * converting them to standard v4l2 sensor drivers using runtime-pm + * ACPI for pm and v4l2_async_register_subdev_sensor() registration. */ - for (subdevs = pdata->subdevs; subdevs->subdev; subdevs++) { + for (subdevs = atomisp_platform_get_subdevs(); subdevs->subdev; subdevs++) { ret = v4l2_device_register_subdev(&isp->v4l2_dev, subdevs->subdev); if (ret) continue; @@ -1186,7 +1179,6 @@ static void atomisp_pm_uninit(struct atomisp_device *isp) static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) { - const struct atomisp_platform_data *pdata; struct atomisp_device *isp; unsigned int start; u32 val; @@ -1195,10 +1187,6 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i /* Pointer to struct device. */ atomisp_dev = &pdev->dev; - pdata = atomisp_get_platform_data(); - if (!pdata) - dev_warn(&pdev->dev, "no platform data available\n"); - start = pci_resource_start(pdev, ATOM_ISP_PCI_BAR); dev_dbg(&pdev->dev, "start: 0x%x\n", start); -- cgit v1.2.3 From cca331a64cffcce1b96ee353bafefa8ff0335240 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 14 Apr 2024 15:40:09 +0100 Subject: media: atomisp: Remove clearing of ISP crop / compose rectangles on file release There is no need to clear the ISP sink-pad crop and source-pad compose rectangles on release of the /dev/video# file. Both will be reset by atomisp_set_fmt() which is guaranteed to get called by atomisp_queue_setup() (if not called already) before another stream starts and thus before these selections are used again. Also the file injection support the comment talks about has long been dropped from the driver. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_fops.c | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_fops.c b/drivers/staging/media/atomisp/pci/atomisp_fops.c index 0d0c1649eaad..50c4123ba006 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_fops.c +++ b/drivers/staging/media/atomisp/pci/atomisp_fops.c @@ -539,7 +539,6 @@ static int atomisp_release(struct file *file) struct atomisp_video_pipe *pipe = atomisp_to_video_pipe(vdev); struct atomisp_sub_device *asd = pipe->asd; struct v4l2_subdev_fh fh; - struct v4l2_rect clear_compose = {0}; v4l2_fh_init(&fh.vfh, vdev); @@ -552,21 +551,6 @@ static int atomisp_release(struct file *file) pipe->users--; - /* - * A little trick here: - * file injection input resolution is recorded in the sink pad, - * therefore can not be cleared when releaseing one device node. - * The sink pad setting can only be cleared when all device nodes - * get released. - */ - { - struct v4l2_mbus_framefmt isp_sink_fmt = { 0 }; - - atomisp_subdev_set_ffmt(&asd->subdev, fh.state, - V4L2_SUBDEV_FORMAT_ACTIVE, - ATOMISP_SUBDEV_PAD_SINK, &isp_sink_fmt); - } - atomisp_css_free_stat_buffers(asd); atomisp_free_internal_buffers(asd); @@ -577,11 +561,6 @@ static int atomisp_release(struct file *file) if (pm_runtime_put_sync(vdev->v4l2_dev->dev) < 0) dev_err(isp->dev, "Failed to power off device\n"); - atomisp_subdev_set_selection(&asd->subdev, fh.state, - V4L2_SUBDEV_FORMAT_ACTIVE, - ATOMISP_SUBDEV_PAD_SOURCE, - V4L2_SEL_TGT_COMPOSE, 0, - &clear_compose); mutex_unlock(&isp->mutex); return 0; } -- cgit v1.2.3 From b0525740af7c1c5cccd9de62677e3d9fdc24b83e Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 14 Apr 2024 15:41:38 +0100 Subject: media: atomisp: Remove empty s_power() op from ISP subdev Remove the empty isp_subdev_set_power() callback. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_subdev.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_subdev.c b/drivers/staging/media/atomisp/pci/atomisp_subdev.c index 1bb33460210c..3a3e84a035e2 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_subdev.c +++ b/drivers/staging/media/atomisp/pci/atomisp_subdev.c @@ -149,18 +149,6 @@ static long isp_subdev_ioctl(struct v4l2_subdev *sd, return 0; } -/* - * isp_subdev_set_power - Power on/off the CCDC module - * @sd: ISP V4L2 subdevice - * @on: power on/off - * - * Return 0 on success or a negative error code otherwise. - */ -static int isp_subdev_set_power(struct v4l2_subdev *sd, int on) -{ - return 0; -} - static int isp_subdev_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh, struct v4l2_event_subscription *sub) @@ -596,7 +584,7 @@ static int isp_subdev_set_format(struct v4l2_subdev *sd, /* V4L2 subdev core operations */ static const struct v4l2_subdev_core_ops isp_subdev_v4l2_core_ops = { - .ioctl = isp_subdev_ioctl, .s_power = isp_subdev_set_power, + .ioctl = isp_subdev_ioctl, .subscribe_event = isp_subdev_subscribe_event, .unsubscribe_event = isp_subdev_unsubscribe_event, }; -- cgit v1.2.3 From 8ff6604cd35e44a822a327ac981b0609c5d5cf83 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 14 Apr 2024 15:45:55 +0100 Subject: media: atomisp: Remove empty s_stream() op from CSI subdev Remove the empty csi2_set_stream() callback and remove the now empty csi2_video_ops struct. While at it also remove the empty csi2_core_ops struct. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_csi2.c | 23 ----------------------- 1 file changed, 23 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_csi2.c b/drivers/staging/media/atomisp/pci/atomisp_csi2.c index e939a09a279b..9288910eeb6c 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_csi2.c +++ b/drivers/staging/media/atomisp/pci/atomisp_csi2.c @@ -141,27 +141,6 @@ static int csi2_set_format(struct v4l2_subdev *sd, &fmt->format); } -/* - * csi2_set_stream - Enable/Disable streaming on the CSI2 module - * @sd: ISP CSI2 V4L2 subdevice - * @enable: Enable/disable stream (1/0) - * - * Return 0 on success or a negative error code otherwise. - */ -static int csi2_set_stream(struct v4l2_subdev *sd, int enable) -{ - return 0; -} - -/* subdev core operations */ -static const struct v4l2_subdev_core_ops csi2_core_ops = { -}; - -/* subdev video operations */ -static const struct v4l2_subdev_video_ops csi2_video_ops = { - .s_stream = csi2_set_stream, -}; - /* subdev pad operations */ static const struct v4l2_subdev_pad_ops csi2_pad_ops = { .enum_mbus_code = csi2_enum_mbus_code, @@ -172,8 +151,6 @@ static const struct v4l2_subdev_pad_ops csi2_pad_ops = { /* subdev operations */ static const struct v4l2_subdev_ops csi2_ops = { - .core = &csi2_core_ops, - .video = &csi2_video_ops, .pad = &csi2_pad_ops, }; -- cgit v1.2.3 From 8ddcec87f2d7f7c5d150884a2c496dd3b4817b40 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 14 Apr 2024 15:51:12 +0100 Subject: media: atomisp: Cleanup atomisp_isr_thread() spinlock handling Refactor the code a tiny bit to avoid the need to have 2 different paths with spin_unlock_irqrestore() in there. While at it also remove the non helpful dev_dbg() message. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_cmd.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp_cmd.c index 9fc2f0af6f3d..29b0873f4ed9 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c +++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c @@ -959,17 +959,14 @@ irqreturn_t atomisp_isr_thread(int irq, void *isp_ptr) { struct atomisp_device *isp = isp_ptr; unsigned long flags; - - dev_dbg(isp->dev, ">%s\n", __func__); + bool streaming; spin_lock_irqsave(&isp->lock, flags); + streaming = isp->asd.streaming; + spin_unlock_irqrestore(&isp->lock, flags); - if (!isp->asd.streaming) { - spin_unlock_irqrestore(&isp->lock, flags); + if (!streaming) return IRQ_HANDLED; - } - - spin_unlock_irqrestore(&isp->lock, flags); /* * The standard CSS2.0 API tells the following calling sequence of -- cgit v1.2.3 From 7a0848d9818c5a00a3c252f1077e142fadcba8db Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 14 Apr 2024 16:00:19 +0100 Subject: media: atomisp: Remove setting of f->fmt.pix.priv from atomisp_set_fmt() This value is not used by the driver, only returned to userspace and userspace should not rely on / use the priv fields. Drop setting this. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/atomisp_cmd.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp_cmd.c index 29b0873f4ed9..102d39a45c9c 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c +++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c @@ -4413,8 +4413,6 @@ int atomisp_set_fmt(struct video_device *vdev, struct v4l2_format *f) atomisp_fill_pix_format(&pipe->pix, f->fmt.pix.width, f->fmt.pix.height, format_bridge); f->fmt.pix = pipe->pix; - f->fmt.pix.priv = PAGE_ALIGN(pipe->pix.width * - pipe->pix.height * 2); dev_dbg(isp->dev, "%s: %dx%d, image size: %d, %d bytes per line\n", __func__, -- cgit v1.2.3 From 19b372d95a5b08da53ed262a45b501029acd44fd Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Tue, 16 Apr 2024 10:19:52 +0100 Subject: media: atomisp: Fix sh_css_config_input_network_2400() coding style Fix the if (stream->config.mode == IA_CSS_INPUT_MODE_PRBS) {} block coding style. Specifically fix the weird declaration of variables split over multiple lines. While at it also split the multi-line width calculation at a more logical place. Reported-by: Andy Shevchenko Signed-off-by: Hans de Goede Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/pci/sh_css.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/pci/sh_css.c b/drivers/staging/media/atomisp/pci/sh_css.c index 6520a35b6e47..42a69b26db01 100644 --- a/drivers/staging/media/atomisp/pci/sh_css.c +++ b/drivers/staging/media/atomisp/pci/sh_css.c @@ -498,17 +498,15 @@ sh_css_config_input_network_2400(struct ia_css_stream *stream) } if (stream->config.mode == IA_CSS_INPUT_MODE_PRBS) { - unsigned int hblank_cycles = 100, - vblank_lines = 6, - width, - height, - vblank_cycles; - width = (stream->config.input_config.input_res.width) / (1 + - (stream->config.pixels_per_clock == 2)); + unsigned int width, height, vblank_cycles; + const unsigned int hblank_cycles = 100; + const unsigned int vblank_lines = 6; + + width = (stream->config.input_config.input_res.width) / + (1 + (stream->config.pixels_per_clock == 2)); height = stream->config.input_config.input_res.height; vblank_cycles = vblank_lines * (width + hblank_cycles); - sh_css_sp_configure_sync_gen(width, height, hblank_cycles, - vblank_cycles); + sh_css_sp_configure_sync_gen(width, height, hblank_cycles, vblank_cycles); } ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE_PRIVATE, "sh_css_config_input_network() leave:\n"); -- cgit v1.2.3 From 6c688cf34c8721ab45c8885f1a76c3fbf8730e92 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Wed, 15 Mar 2023 09:09:04 +0000 Subject: media: atomisp-mt9m114: adjust macro parameter name The macro parameter name, sd, captures the field name in the third argument of container_of. Fortunately, the argument at all uses is actually sd. But change the macro parameter name anyway, for a little added safety. Link: https://lore.kernel.org/linux-media/20230315090904.20092-1-Julia.Lawall@inria.fr Signed-off-by: Julia Lawall Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c b/drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c index 03ebee976d5b..23b1001c2a55 100644 --- a/drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c +++ b/drivers/staging/media/atomisp/i2c/atomisp-mt9m114.c @@ -35,7 +35,7 @@ #include "mt9m114.h" -#define to_mt9m114_sensor(sd) container_of(sd, struct mt9m114_device, sd) +#define to_mt9m114_sensor(s) container_of(s, struct mt9m114_device, sd) /* * TODO: use debug parameter to actually define when debug messages should -- cgit v1.2.3 From 843a9f4a7a85988f2f3af98adf21797c2fd05ab1 Mon Sep 17 00:00:00 2001 From: Víctor Gonzalo Date: Thu, 14 Sep 2023 14:51:00 +0100 Subject: media: ipu3: Use MODULE_FIRMWARE to add firmware files metadata MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ipu3 driver requests firmware files but does not use the MODULE_FIRMWARE macro to show them in the module metadata [mchehab: add missing firmware file: IMGU_FW_NAME_IPU_20161208] Link: https://lore.kernel.org/linux-media/20230914135100.19911-1-victor.gonzalo@anddroptable.net Signed-off-by: Víctor Gonzalo Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/ipu3/ipu3.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/staging') diff --git a/drivers/staging/media/ipu3/ipu3.c b/drivers/staging/media/ipu3/ipu3.c index 215884b3e922..e22a9c092195 100644 --- a/drivers/staging/media/ipu3/ipu3.c +++ b/drivers/staging/media/ipu3/ipu3.c @@ -13,6 +13,7 @@ #include #include "ipu3.h" +#include "ipu3-css-fw.h" #include "ipu3-dmamap.h" #include "ipu3-mmu.h" @@ -860,3 +861,6 @@ MODULE_AUTHOR("Yuning Pu"); MODULE_AUTHOR("Yong Zhi "); MODULE_LICENSE("GPL v2"); MODULE_DESCRIPTION("Intel ipu3_imgu PCI driver"); +MODULE_FIRMWARE(IMGU_FW_NAME); +MODULE_FIRMWARE(IMGU_FW_NAME_20161208); +MODULE_FIRMWARE(IMGU_FW_NAME_IPU_20161208); -- cgit v1.2.3 From a1c6d22421501fc1016b99ac8570a1030714c70f Mon Sep 17 00:00:00 2001 From: Ihor Matushchak Date: Sat, 14 Oct 2023 15:38:43 +0100 Subject: media: staging: max96712: fix copy-paste error Link: https://lore.kernel.org/linux-media/20231014143843.3409-1-ihor.matushchak@foobox.net Signed-off-by: Ihor Matushchak Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/max96712/max96712.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/max96712/max96712.c b/drivers/staging/media/max96712/max96712.c index c44145284aa1..ea67bcf69c9d 100644 --- a/drivers/staging/media/max96712/max96712.c +++ b/drivers/staging/media/max96712/max96712.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* - * Maxim MAX9286 Quad GMSL2 Deserializer Driver + * Maxim MAX96712 Quad GMSL2 Deserializer Driver * * Copyright (C) 2021 Renesas Electronics Corporation * Copyright (C) 2021 Niklas Söderlund -- cgit v1.2.3 From 776f1bde345d0e21e31de766d94154f77f6bf1cd Mon Sep 17 00:00:00 2001 From: Changhuang Liang Date: Tue, 12 Mar 2024 02:45:20 +0000 Subject: media: staging: media: starfive: Clean pad selection in isp_try_format() The code to select isp_dev->formats[] is overly complicated. We can just use the "pad" as the index. This will making adding new pads easier in future patches. No functional change. Link: https://lore.kernel.org/linux-media/20240312024520.11022-1-changhuang.liang@starfivetech.com Signed-off-by: Changhuang Liang Reviewed-by: Dan Carpenter Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/starfive/camss/stf-isp.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/starfive/camss/stf-isp.c b/drivers/staging/media/starfive/camss/stf-isp.c index d50616ef351e..4e6e26736852 100644 --- a/drivers/staging/media/starfive/camss/stf-isp.c +++ b/drivers/staging/media/starfive/camss/stf-isp.c @@ -10,9 +10,6 @@ #include "stf-camss.h" -#define SINK_FORMATS_INDEX 0 -#define SOURCE_FORMATS_INDEX 1 - static int isp_set_selection(struct v4l2_subdev *sd, struct v4l2_subdev_state *state, struct v4l2_subdev_selection *sel); @@ -94,10 +91,7 @@ static void isp_try_format(struct stf_isp_dev *isp_dev, return; } - if (pad == STF_ISP_PAD_SINK) - formats = &isp_dev->formats[SINK_FORMATS_INDEX]; - else if (pad == STF_ISP_PAD_SRC) - formats = &isp_dev->formats[SOURCE_FORMATS_INDEX]; + formats = &isp_dev->formats[pad]; fmt->width = clamp_t(u32, fmt->width, STFCAMSS_FRAME_MIN_WIDTH, STFCAMSS_FRAME_MAX_WIDTH); @@ -123,7 +117,7 @@ static int isp_enum_mbus_code(struct v4l2_subdev *sd, if (code->index >= ARRAY_SIZE(isp_formats_sink)) return -EINVAL; - formats = &isp_dev->formats[SINK_FORMATS_INDEX]; + formats = &isp_dev->formats[code->pad]; code->code = formats->fmts[code->index].code; } else { struct v4l2_mbus_framefmt *sink_fmt; -- cgit v1.2.3 From cfffeef587e3227ecc2b31de90d6a13d8fa54150 Mon Sep 17 00:00:00 2001 From: Ricardo Ribalda Date: Mon, 29 Apr 2024 16:04:46 +0100 Subject: media: staging: sun6i-isp: Remove redundant printk platform_get_irq() already prints an error for us. Found by cocci: drivers/staging/media/sunxi/sun6i-isp/sun6i_isp.c:389:2-9: line 389 is redundant because platform_get_irq() already prints an error Link: https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-7-3c4865f5a4b0@chromium.org Acked-by: Jernej Skrabec Signed-off-by: Ricardo Ribalda Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/sunxi/sun6i-isp/sun6i_isp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp.c b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp.c index 5c0a45394cba..58f8ae92320d 100644 --- a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp.c +++ b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp.c @@ -386,8 +386,7 @@ static int sun6i_isp_resources_setup(struct sun6i_isp_device *isp_dev, irq = platform_get_irq(platform_dev, 0); if (irq < 0) { - dev_err(dev, "failed to get interrupt\n"); - ret = -ENXIO; + ret = irq; goto error_clock_rate_exclusive; } -- cgit v1.2.3 From 6a56625b9e64593339937072897938f673de8a80 Mon Sep 17 00:00:00 2001 From: Ricardo Ribalda Date: Mon, 29 Apr 2024 16:04:49 +0100 Subject: media: staging: media: tegra-video: Use swap macro Makes the code simpler and cocci happier: drivers/staging/media/tegra-video/tegra20.c:324:44-45: WARNING opportunity for swap() Link: https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-10-3c4865f5a4b0@chromium.org Signed-off-by: Ricardo Ribalda Reviewed-by: Luca Ceresoli Signed-off-by: Mauro Carvalho Chehab --- drivers/staging/media/tegra-video/tegra20.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/media/tegra-video/tegra20.c b/drivers/staging/media/tegra-video/tegra20.c index 630e2ff987a3..7b8f8f810b35 100644 --- a/drivers/staging/media/tegra-video/tegra20.c +++ b/drivers/staging/media/tegra-video/tegra20.c @@ -317,13 +317,8 @@ static void tegra20_channel_queue_setup(struct tegra_vi_channel *chan) chan->addr_offset_v = chan->addr_offset_u + stride * height / 4; /* For YVU420, we swap the locations of the U and V planes. */ - if (chan->format.pixelformat == V4L2_PIX_FMT_YVU420) { - unsigned long temp; - - temp = chan->addr_offset_u; - chan->addr_offset_u = chan->addr_offset_v; - chan->addr_offset_v = temp; - } + if (chan->format.pixelformat == V4L2_PIX_FMT_YVU420) + swap(chan->addr_offset_u, chan->addr_offset_v); chan->start_offset_u = chan->addr_offset_u; chan->start_offset_v = chan->addr_offset_v; -- cgit v1.2.3