media: atomisp: Register only 1 /dev/video# node + cleanups
Subsystems (4)
cover media: atomisp: Register only 1 /dev/video# node + cleanups
Hi All,
Here is an atomisp patch-series to continue the simplification / exotic feature removal of atomisp. Specifically this series makes atomisp register only 1 /dev/video# node.
The other patches are some preparation + follow-up work for this change, as well as a whole bunch of folow-up clean-ups.
The cleanups focus on removing the various count / users functions which atomisp used before when there were multiple nodes. This is preparation work for eventually allowing opening the same node multipe-times, as is normal for standard v4l2 /dev/video# nodes.
Regards,
Hans
Hans de Goede (30):
media: atomisp: Remove res_overflow parameter from atomisp_try_fmt()
media: atomisp: Remove Continuous capture and SDV run-modes
media: atomisp: Remove isp->need_gfx_throttle field
media: atomisp: Drop atomisp_get_css_buf_type()
media: atomisp: Replace source-pad checks with run-mode checks
media: atomisp: Register only 1 /dev/video# node
media: atomisp: Drop atomisp_is_vf_pipe()
media: atomisp: Rename video_out_preview to video_out
media: atomisp: Remove source_pad parameter from functions and structs
media: atomisp: Remove 1 line atomisp_flush_bufs_and_wakeup() helper
media: atomisp: Remove atomisp_subdev_register_video_nodes() helper
media: atomisp: Remove a bunch of unused atomisp_css_*() functions
media: atomisp: Remove unused mipi_frame_size field from
atomisp_[sub_]device
media: atomisp: Remove isp_timeout flag
media: atomisp: Remove atomisp_sensor_start_stream()
media: atomisp: Simplify atomisp_[start|stop]_streaming()
media: atomisp: Simplify atomisp_css_[start|stop]()
media: atomisp: Simplify atomisp_open() and atomisp_release()
media: atomisp: Simplify atomisp_pipe_check()
media: atomisp: Turn asd->streaming state tracker into a bool
media: atomisp: Remove no longer used atomisp_css_flush()
media: atomisp: Remove atomisp_streaming_count()
media: atomisp: Simplify atomisp_isr() and recovery_work()
media: atomisp: Rename atomisp_destroy_pipes_stream_force() to
atomisp_destroy_pipes_stream()
media: atomisp: Allow system suspend to continue with open /dev/video#
nodes
media: atomisp: Remove atomisp_[sub]dev_users()
media: atomisp: Remove unused css_pipe_id argument from
atomisp_css_[start|stop]()
media: atomisp: Remove unused atomisp_get_css_pipe_id() function
media: atomisp: Remove in_reset argument from atomisp_css_start()
media: atomisp: Set asd.subdev.devnode once from
isp_subdev_init_entities()
.../media/atomisp/include/linux/atomisp.h | 5 +- .../staging/media/atomisp/pci/atomisp_cmd.c | 371 ++++++------------ .../staging/media/atomisp/pci/atomisp_cmd.h | 8 +- .../media/atomisp/pci/atomisp_compat.h | 41 +- .../media/atomisp/pci/atomisp_compat_css20.c | 283 ++----------- .../staging/media/atomisp/pci/atomisp_drvfs.c | 2 +- .../staging/media/atomisp/pci/atomisp_fops.c | 176 +-------- .../staging/media/atomisp/pci/atomisp_fops.h | 3 - .../media/atomisp/pci/atomisp_internal.h | 9 - .../staging/media/atomisp/pci/atomisp_ioctl.c | 212 ++-------- .../staging/media/atomisp/pci/atomisp_ioctl.h | 5 - .../media/atomisp/pci/atomisp_subdev.c | 198 ++-------- .../media/atomisp/pci/atomisp_subdev.h | 30 +- .../staging/media/atomisp/pci/atomisp_v4l2.c | 120 +----- 14 files changed, 254 insertions(+), 1209 deletions(-)
Signature · 1 line
2.40.1
PATCH 1/30 media: atomisp: Remove res_overflow parameter from atomisp_try_fmt()
The only remaining caller of atomisp_try_fmt() always passes NULL for the res_overflow parameter. Drop it and simplify atomisp_try_fmt().
--- .../staging/media/atomisp/pci/atomisp_cmd.c | 21 ++++--------------- .../staging/media/atomisp/pci/atomisp_cmd.h | 3 +-- .../staging/media/atomisp/pci/atomisp_ioctl.c | 2 +- 3 files changed, 6 insertions(+), 20 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_cmd.c +4 -17
@@ -3881,8 +3881,7 @@ static void __atomisp_init_stream_info(u16 stream_index, }/* This function looks up the closest available resolution. */ -int atomisp_try_fmt (struct video_device *vdev,struct v4l2_pix_format *f, -bool *res_overflow) +int atomisp_try_fmt (struct video_device *vdev,struct v4l2_pix_format *f) {struct atomisp_device *isp =video_get_drvdata (vdev);struct atomisp_sub_device *asd =atomisp_to_video_pipe (vdev)->asd;
@@ -3940,6 +3939,8 @@ int atomisp_try_fmt(struct video_device *vdev, struct v4l2_pix_format *f, } f->pixelformat = fmt->pixelformat; + f->width = format.format.width; + f->height = format.format.height;/* * If the format is jpeg or custom RAW, then the width and height will
@@ -3948,22 +3949,8 @@ int atomisp_try_fmt(struct video_device *vdev, struct v4l2_pix_format *f,* the sensor driver. */ if (f->pixelformat ==V4L2_PIX_FMT_JPEG || - f->pixelformat ==V4L2_PIX_FMT_CUSTOM_M10MO_RAW ) { - f->width = format.format.width; - f->height = format.format.height; + f->pixelformat ==V4L2_PIX_FMT_CUSTOM_M10MO_RAW )return 0 ; - } - -if (!res_overflow || (format.format.width < f->width && - format.format.height < f->height)) { - f->width = format.format.width; - f->height = format.format.height; -/* Set the flag when resolution requested is -* beyond the max value supported by sensor -*/ -if (res_overflow) - *res_overflow = true; - }/* app vs isp */ f->width = rounddown(clamp_t(u32, f->width, ATOM_ISP_MIN_WIDTH,
drivers/staging/media/atomisp/pci/atomisp_cmd.h +1 -2
@@ -259,8 +259,7 @@ int atomisp_compare_grid(struct atomisp_sub_device *asd, struct atomisp_grid_info *atomgrid);/* This function looks up the closest available resolution. */ -int atomisp_try_fmt (struct video_device *vdev,struct v4l2_pix_format *f, -bool *res_overflow); +int atomisp_try_fmt (struct video_device *vdev,struct v4l2_pix_format *f);int atomisp_set_fmt (struct video_device *vdev,struct v4l2_format *f);
drivers/staging/media/atomisp/pci/atomisp_ioctl.c +1 -1
@@ -896,7 +896,7 @@ static int atomisp_try_fmt_cap(struct file *file, void *fh, f->fmt.pix.width += pad_w; f->fmt.pix.height += pad_h; - ret =atomisp_try_fmt (vdev, &f->fmt.pix,NULL ); + ret =atomisp_try_fmt (vdev, &f->fmt.pix);if (ret)return ret;
Signature · 1 line
2.40.1
PATCH 2/30 media: atomisp: Remove Continuous capture and SDV run-modes
In reply to Hans de GoedeSince we no longer support Continuous mode, setting the run_mode to ATOMISP_RUN_MODE_CONTINUOUS_CAPTURE no longer make sense, so remove this.
While at it also remove ATOMISP_RUN_MODE_SDV, which was never exposed to userspace in the first place.
--- .../media/atomisp/include/linux/atomisp.h | 5 +- .../media/atomisp/pci/atomisp_compat_css20.c | 12 --- .../staging/media/atomisp/pci/atomisp_ioctl.c | 3 - .../media/atomisp/pci/atomisp_subdev.c | 5 +- .../staging/media/atomisp/pci/atomisp_v4l2.c | 91 ------------------- 5 files changed, 3 insertions(+), 113 deletions(-)
drivers/staging/media/atomisp/include/linux/atomisp.h +1 -4
@@ -38,7 +38,6 @@#define CI_MODE_PREVIEW 0x8000#define CI_MODE_VIDEO 0x4000#define CI_MODE_STILL_CAPTURE 0x2000 -#define CI_MODE_CONTINUOUS 0x1000#define CI_MODE_NONE 0x0000#define OUTPUT_MODE_FILE 0x0100
@@ -1059,9 +1058,7 @@ struct atomisp_sensor_ae_bracketing_lut {#define V4L2_CID_RUN_MODE (V4L2_CID_CAMERA_LASTP1 + 20)#define ATOMISP_RUN_MODE_VIDEO 1#define ATOMISP_RUN_MODE_STILL_CAPTURE 2 -#define ATOMISP_RUN_MODE_CONTINUOUS_CAPTURE 3 -#define ATOMISP_RUN_MODE_PREVIEW 4 -#define ATOMISP_RUN_MODE_SDV 5 +#define ATOMISP_RUN_MODE_PREVIEW 3#define V4L2_CID_ENABLE_VFPP (V4L2_CID_CAMERA_LASTP1 + 21)#define V4L2_CID_ATOMISP_CONTINUOUS_MODE (V4L2_CID_CAMERA_LASTP1 + 22)
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +0 -12
@@ -649,23 +649,11 @@ static bool is_pipe_valid_to_current_run_mode(struct atomisp_sub_device *asd,if (pipe_id ==IA_CSS_PIPE_ID_PREVIEW )return true; -return false; -case ATOMISP_RUN_MODE_CONTINUOUS_CAPTURE : -if (pipe_id ==IA_CSS_PIPE_ID_CAPTURE || - pipe_id ==IA_CSS_PIPE_ID_PREVIEW ) -return true; -return false;case ATOMISP_RUN_MODE_VIDEO :if (pipe_id ==IA_CSS_PIPE_ID_VIDEO || pipe_id ==IA_CSS_PIPE_ID_YUVPP )return true; -return false; -case ATOMISP_RUN_MODE_SDV : -if (pipe_id ==IA_CSS_PIPE_ID_CAPTURE || - pipe_id ==IA_CSS_PIPE_ID_VIDEO ) -return true; -return false; }
drivers/staging/media/atomisp/pci/atomisp_ioctl.c +0 -3
@@ -1902,9 +1902,6 @@ static int atomisp_s_parm(struct file *file, void *fh,case CI_MODE_STILL_CAPTURE : mode =ATOMISP_RUN_MODE_STILL_CAPTURE ;break ; -case CI_MODE_CONTINUOUS : - mode =ATOMISP_RUN_MODE_CONTINUOUS_CAPTURE ; -break ;case CI_MODE_PREVIEW : mode =ATOMISP_RUN_MODE_PREVIEW ;break ;
drivers/staging/media/atomisp/pci/atomisp_subdev.c +2 -3
@@ -758,7 +758,6 @@ static const char *const ctrl_run_mode_menu[] = {NULL ,"Video" ,"Still capture" , -"Continuous capture" , "Preview", };
@@ -769,7 +768,7 @@ static const struct v4l2_ctrl_config ctrl_run_mode = { .type = V4L2_CTRL_TYPE_MENU, .min = 1, .def = 1, - .max = 4, + .max = 3, .qmenu = ctrl_run_mode_menu, };
@@ -971,7 +970,7 @@ static int isp_subdev_init_entities(struct atomisp_sub_device *asd)return ret; ret =atomisp_video_init (&asd->video_out_vf,"VIEWFINDER" , -ATOMISP_RUN_MODE_CONTINUOUS_CAPTURE ); +ATOMISP_RUN_MODE_STILL_CAPTURE );if (ret <0 )return ret;
drivers/staging/media/atomisp/pci/atomisp_v4l2.c +0 -91
163 lines not on this page · raw message
Signature · 1 line
2.40.1
Re: [PATCH 02/30] media: atomisp: Remove Continuous capture and SDV run-modes
Quoted 6 lines · Hans de Goede
Since we no longer support Continuous mode, setting the
run_modetoATOMISP_RUN_MODE_CONTINUOUS_CAPTUREno longer make sense, so remove this.While at it also remove
ATOMISP_RUN_MODE_SDV, which was never exposed
it, also
Quoted 1 line
to userspace in the first place.
...
drivers/staging/media/atomisp/include/linux/atomisp.h struct atomisp_sensor_ae_bracketing_lut { · line 1061
Quoted 7 lines
#define V4L2_CID_RUN_MODE (V4L2_CID_CAMERA_LASTP1 + 20) #define ATOMISP_RUN_MODE_VIDEO 1 #define ATOMISP_RUN_MODE_STILL_CAPTURE 2drivers/staging/media/atomisp/include/linux/atomisp.h +1
-3-#define ATOMISP_RUN_MODE_CONTINUOUS_CAPTURE 3 -#define ATOMISP_RUN_MODE_PREVIEW 4 -#define ATOMISP_RUN_MODE_SDV 5 +#define ATOMISP_RUN_MODE_PREVIEW 3
Wouldn't it be better to add here a _MODE_MIN and _MODE_MAX and... (see at the end of this message)
...
drivers/staging/media/atomisp/pci/atomisp_subdev.c static const char *const ctrl_run_mode_menu[] = { · line 761
Quoted 6 lines
drivers/staging/media/atomisp/pci/atomisp_subdev.c +0
-1@@ -758,7 +758,6 @@ static const char *const ctrl_run_mode_menu[] = {NULL ,"Video" ,"Still capture" , -"Continuous capture" , "Preview",
Wouldn't be more robust to use indices like
[_MODE_PREVIEW] = "Preview",
?
...
drivers/staging/media/atomisp/pci/atomisp_subdev.c static const struct v4l2_ctrl_config ctrl_run_mode = { · line 771
Quoted 5 lines
drivers/staging/media/atomisp/pci/atomisp_subdev.c +0
-0.type = V4L2_CTRL_TYPE_MENU, .min = 1,.def = 1,drivers/staging/media/atomisp/pci/atomisp_subdev.c +1
-1- .max = 4, + .max = 3,
...use it here? Or did I miss these min and max meanings?
Quoted 1 line
.qmenu =
ctrl_run_mode_menu,
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH 3/30 media: atomisp: Remove isp->need_gfx_throttle field
In reply to Hans de GoedeRemove the isp->need_gfx_throttle field it is only ever set and never read.
Also the code setting it is broken, comparing run_mode->val to ATOMISP_SUBDEV_PAD_SOURCE_VIDEO which are not of the same type / not part of the same enum.
--- drivers/staging/media/atomisp/pci/atomisp_cmd.c | 10 ---------- drivers/staging/media/atomisp/pci/atomisp_fops.c | 1 - drivers/staging/media/atomisp/pci/atomisp_internal.h | 2 -- 3 files changed, 13 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_cmd.c +0 -10
@@ -4693,16 +4693,6 @@ int atomisp_set_fmt(struct video_device *vdev, struct v4l2_format *f) f->fmt.pix = pipe->pix; f->fmt.pix.priv =PAGE_ALIGN (pipe->pix.width * pipe->pix.height *2 ); - -/* -* If in video 480P case, no GFX throttle -*/ -if (asd->run_mode->val ==ATOMISP_SUBDEV_PAD_SOURCE_VIDEO && - f->fmt.pix.width ==720 && f->fmt.pix.height ==480 ) - isp->need_gfx_throttle = false; -else - isp->need_gfx_throttle = true; -/* Report the needed sizes */ f->fmt.pix.sizeimage = pipe->pix.sizeimage; f->fmt.pix.bytesperline = pipe->pix.bytesperline;
drivers/staging/media/atomisp/pci/atomisp_fops.c +0 -1
@@ -539,7 +539,6 @@ static void atomisp_dev_init_struct(struct atomisp_device *isp) {unsigned int i; - isp->need_gfx_throttle = true; isp->isp_fatal_error = false; isp->mipi_frame_size =0 ;
drivers/staging/media/atomisp/pci/atomisp_internal.h +0 -2
@@ -211,8 +211,6 @@ struct atomisp_device {spinlock_t lock;/* Protects asd.streaming */ -bool need_gfx_throttle; -unsigned int mipi_frame_size;const struct atomisp_dfs_config *dfs;unsigned int hpll_freq;
Signature · 1 line
2.40.1
PATCH 4/30 media: atomisp: Drop atomisp_get_css_buf_type()
In reply to Hans de GoedeSince continuous mode has been removed, there no longer is the option for separate capture output + viewfinder output streams at the same time.
So all buffers queued by userspace are now for the normal output stream, remove atomisp_get_css_buf_type() and always use IA_CSS_BUFFER_TYPE_OUTPUT_FRAME for buffers queued by userspace.
--- .../staging/media/atomisp/pci/atomisp_fops.c | 29 +------------------ 1 file changed, 1 insertion(+), 28 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_fops.c +1 -28
@@ -342,24 +342,10 @@ static int atomisp_q_video_buffers_to_css(struct atomisp_sub_device *asd,return 0 ; } -static int atomisp_get_css_buf_type (struct atomisp_sub_device *asd, -enum ia_css_pipe_id pipe_id, -uint16_t source_pad) -{ -if (pipe_id ==IA_CSS_PIPE_ID_COPY || - source_pad ==ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE || - source_pad ==ATOMISP_SUBDEV_PAD_SOURCE_VIDEO || - (source_pad ==ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW && - asd->run_mode->val !=ATOMISP_RUN_MODE_VIDEO )) -return IA_CSS_BUFFER_TYPE_OUTPUT_FRAME ; -else -return IA_CSS_BUFFER_TYPE_VF_OUTPUT_FRAME ; -} -/* queue all available buffers to css */ int atomisp_qbuffers_to_css (struct atomisp_sub_device *asd) { -enum ia_css_buffer_type buf_type; +const enum ia_css_buffer_type buf_type =IA_CSS_BUFFER_TYPE_OUTPUT_FRAME ;enum ia_css_pipe_id css_capture_pipe_id =IA_CSS_PIPE_ID_NUM ;enum ia_css_pipe_id css_preview_pipe_id =IA_CSS_PIPE_ID_NUM ;enum ia_css_pipe_id css_video_pipe_id =IA_CSS_PIPE_ID_NUM ;
@@ -400,9 +386,6 @@ int atomisp_qbuffers_to_css(struct atomisp_sub_device *asd) }if (capture_pipe) { - buf_type =atomisp_get_css_buf_type ( - asd, css_capture_pipe_id, -atomisp_subdev_source_pad (&capture_pipe->vdev)); input_stream_id =ATOMISP_INPUT_STREAM_GENERAL ; atomisp_q_video_buffers_to_css(asd, capture_pipe,
@@ -411,9 +394,6 @@ int atomisp_qbuffers_to_css(struct atomisp_sub_device *asd) }if (vf_pipe) { - buf_type =atomisp_get_css_buf_type ( - asd, css_capture_pipe_id, -atomisp_subdev_source_pad (&vf_pipe->vdev));if (asd->stream_env[ATOMISP_INPUT_STREAM_POSTVIEW ].stream) input_stream_id =ATOMISP_INPUT_STREAM_POSTVIEW ;else
@@ -425,10 +405,6 @@ int atomisp_qbuffers_to_css(struct atomisp_sub_device *asd) }if (preview_pipe) { - buf_type =atomisp_get_css_buf_type ( - asd, css_preview_pipe_id, -atomisp_subdev_source_pad (&preview_pipe->vdev)); -if (css_preview_pipe_id ==IA_CSS_PIPE_ID_YUVPP ) input_stream_id =ATOMISP_INPUT_STREAM_VIDEO ;else if (asd->stream_env[ATOMISP_INPUT_STREAM_PREVIEW ].stream)
@@ -442,9 +418,6 @@ int atomisp_qbuffers_to_css(struct atomisp_sub_device *asd) }if (video_pipe) { - buf_type =atomisp_get_css_buf_type ( - asd, css_video_pipe_id, -atomisp_subdev_source_pad (&video_pipe->vdev));if (asd->stream_env[ATOMISP_INPUT_STREAM_VIDEO ].stream) input_stream_id =ATOMISP_INPUT_STREAM_VIDEO ;else
Signature · 1 line
2.40.1
PATCH 5/30 media: atomisp: Replace source-pad checks with run-mode checks
In reply to Hans de GoedeCurrently atomisp behavior is determined by a mix of which /dev/video# node (which isp-subdev source-pad) is opened + which run-mode is set. With various combinations not being allowed and likely leading to crashes due to lack of error checking.
Now that we no longer support continuous mode and thus no longer support streaming from 2 /dev/video# nodes at the same time, there is no need to have a separate /dev/video# node for each run-mode. Instead the plan is to support the 3 different run-modes on a single /dev/video# node. Since we are moving to a single isp-subdev source-pad, the behavior should then be solely and consistently be defined by the run-mode.
Replace various source-pad checks with run-mode checks in preparation for moving to a single source-pad. In some places the new run-mode checks overlap with existing run-mode checks and the checks are folded together into a single check.
This removes handling of the ATOMISP_SUBDEV_PAD_SOURCE_VF source-pad, this source-pad was only useful for continuous mode, for which support has been removed.
Note that currently the only run-mode which we actually have been able to get to work is the video-capture with scaler aka preview mode and as such that is also the only run-mode tested. This patch is intended to preserve the current (known to not work 100%) behavior of the other run-modes, so that those maybe can be enabled later.
--- .../staging/media/atomisp/pci/atomisp_cmd.c | 37 +++------- .../media/atomisp/pci/atomisp_compat_css20.c | 72 ++++--------------- .../media/atomisp/pci/atomisp_subdev.c | 23 ++---- 3 files changed, 29 insertions(+), 103 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_cmd.c +10 -27
@@ -4215,21 +4215,12 @@ static int atomisp_set_fmt_to_isp(struct video_device *vdev, ATOMISP_SUBDEV_PAD_SOURCE_VF, &vf_ffmt); asd->video_out_vf.sh_fmt =IA_CSS_FRAME_FORMAT_NV12 ; -if (asd->vfpp->val ==ATOMISP_VFPP_DISABLE_SCALER ) { +if (asd->run_mode->val ==ATOMISP_RUN_MODE_VIDEO || + asd->vfpp->val ==ATOMISP_VFPP_DISABLE_SCALER ) {atomisp_css_video_configure_viewfinder (asd, vf_size.width, vf_size.height,0 , asd->video_out_vf.sh_fmt); - }else if (asd->run_mode->val ==ATOMISP_RUN_MODE_VIDEO ) { -if (source_pad ==ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW || - source_pad ==ATOMISP_SUBDEV_PAD_SOURCE_VIDEO ) -atomisp_css_video_configure_viewfinder (asd, - vf_size.width, vf_size.height,0 , - asd->video_out_vf.sh_fmt); -else -atomisp_css_capture_configure_viewfinder (asd, - vf_size.width, vf_size.height,0 , - asd->video_out_vf.sh_fmt); - }else if (source_pad !=ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW || + }else if (asd->run_mode->val ==ATOMISP_RUN_MODE_STILL_CAPTURE || asd->vfpp->val ==ATOMISP_VFPP_DISABLE_LOWLAT ) { atomisp_css_capture_configure_viewfinder(asd, vf_size.width, vf_size.height, 0,
@@ -4255,7 +4246,7 @@ static int atomisp_set_fmt_to_isp(struct video_device *vdev, configure_output = atomisp_css_video_configure_output; get_frame_info = atomisp_css_video_get_output_frame_info; pipe_id =IA_CSS_PIPE_ID_VIDEO ; - }else if (source_pad ==ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW ) { + }else if (asd->run_mode->val ==ATOMISP_RUN_MODE_PREVIEW ) { configure_output = atomisp_css_preview_configure_output; get_frame_info = atomisp_css_preview_get_output_frame_info; configure_pp_input = atomisp_css_preview_configure_pp_input;
@@ -4386,7 +4377,6 @@ static int atomisp_set_fmt_to_snr(struct video_device *vdev, const struct v4l2_pstruct atomisp_device *isp;struct atomisp_input_stream_info *stream_info = (struct atomisp_input_stream_info *)ffmt->reserved; -int source_pad =atomisp_subdev_source_pad (vdev);struct v4l2_subdev_fh fh;int ret;
@@ -4417,8 +4407,7 @@ static int atomisp_set_fmt_to_snr(struct video_device *vdev, const struct v4l2_p req_ffmt = ffmt;/* Disable dvs if resolution can't be supported by sensor */ -if (asd->params.video_dis_en && - source_pad ==ATOMISP_SUBDEV_PAD_SOURCE_VIDEO ) { +if (asd->params.video_dis_en && asd->run_mode->val ==ATOMISP_RUN_MODE_VIDEO ) { vformat.which =V4L2_SUBDEV_FORMAT_TRY ; ret =v4l2_subdev_call (isp->inputs[asd->input_curr].camera, pad, set_fmt, &pad_state, &vformat);
@@ -4453,8 +4442,7 @@ static int atomisp_set_fmt_to_snr(struct video_device *vdev, const struct v4l2_p ffmt->height < ATOM_ISP_STEP_HEIGHT)return -EINVAL ; -if (asd->params.video_dis_en && - source_pad ==ATOMISP_SUBDEV_PAD_SOURCE_VIDEO && +if (asd->params.video_dis_en && asd->run_mode->val ==ATOMISP_RUN_MODE_VIDEO && (ffmt->width < req_ffmt->width || ffmt->height < req_ffmt->height)) {dev_warn (isp->dev,"can not enable video dis due to sensor limitation." );
@@ -5005,16 +4993,11 @@ static int atomisp_get_pipe_id(struct atomisp_video_pipe *pipe)return IA_CSS_PIPE_ID_VIDEO ; }else if (asd->vfpp->val ==ATOMISP_VFPP_DISABLE_LOWLAT ) {return IA_CSS_PIPE_ID_CAPTURE ; - }else if (pipe == &asd->video_out_video_capture) { + }else if (asd->run_mode->val ==ATOMISP_RUN_MODE_VIDEO ) {return IA_CSS_PIPE_ID_VIDEO ; - }else if (pipe == &asd->video_out_vf) { -return IA_CSS_PIPE_ID_CAPTURE ; - }else if (pipe == &asd->video_out_preview) { -if (asd->run_mode->val ==ATOMISP_RUN_MODE_VIDEO ) -return IA_CSS_PIPE_ID_VIDEO ; -else -return IA_CSS_PIPE_ID_PREVIEW ; - }else if (pipe == &asd->video_out_capture) { + }else if (asd->run_mode->val ==ATOMISP_RUN_MODE_PREVIEW ) { +return IA_CSS_PIPE_ID_PREVIEW ; + }else if (asd->run_mode->val ==ATOMISP_RUN_MODE_STILL_CAPTURE ) {if (asd->copy_mode)return IA_CSS_PIPE_ID_COPY ;else
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +13 -59
95 lines not on this page · raw message
drivers/staging/media/atomisp/pci/atomisp_subdev.c +6 -17
@@ -393,8 +393,7 @@ int atomisp_subdev_set_selection(struct v4l2_subdev *sd, r->width =rounddown (r->width,ATOM_ISP_STEP_WIDTH ); r->height =rounddown (r->height,ATOM_ISP_STEP_HEIGHT ); -switch (pad) { -case ATOMISP_SUBDEV_PAD_SINK : { +if (pad ==ATOMISP_SUBDEV_PAD_SINK ) {/* Only crop target supported on sink pad. */ unsigned int dvs_w, dvs_h;
@@ -445,7 +444,7 @@ int atomisp_subdev_set_selection(struct v4l2_subdev *sd, }if (which ==V4L2_SUBDEV_FORMAT_TRY ) -break ; + goto get_rect;if (isp_sd->params.video_dis_en && isp_sd->run_mode->val ==ATOMISP_RUN_MODE_VIDEO ) {
@@ -468,12 +467,8 @@ int atomisp_subdev_set_selection(struct v4l2_subdev *sd,ATOMISP_INPUT_STREAM_GENERAL , crop[pad]->width, crop[pad]->height); -break ; - } -case ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE : -case ATOMISP_SUBDEV_PAD_SOURCE_VIDEO : { + }else if (isp_sd->run_mode->val !=ATOMISP_RUN_MODE_PREVIEW ) {/* Only compose target is supported on source pads. */ -if (isp_sd->vfpp->val ==ATOMISP_VFPP_DISABLE_LOWLAT ) {/* Scaling is disabled in this mode */ r->width = crop[ATOMISP_SUBDEV_PAD_SINK ]->width;
@@ -492,7 +487,7 @@ int atomisp_subdev_set_selection(struct v4l2_subdev *sd,if (r->width ==0 || r->height ==0 || crop[ATOMISP_SUBDEV_PAD_SINK ]->width ==0 || crop[ATOMISP_SUBDEV_PAD_SINK ]->height ==0 ) -break ; + goto get_rect;/* * do cropping on sensor input if ratio of required resolution * is different with sensor output resolution ratio:
@@ -522,18 +517,12 @@ int atomisp_subdev_set_selection(struct v4l2_subdev *sd,rounddown (crop[ATOMISP_SUBDEV_PAD_SINK ]-> width * r->height / r->width, ATOM_ISP_STEP_WIDTH)); - -break ; - } -case ATOMISP_SUBDEV_PAD_SOURCE_VF : -case ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW : + }else { comp[pad]->width = r->width; comp[pad]->height = r->height; -break ; -default : -return -EINVAL ; } +get_rect:/* Set format dimensions on non-sink pads as well. */ if (pad !=ATOMISP_SUBDEV_PAD_SINK ) { ffmt[pad]->width = comp[pad]->width;
Signature · 1 line
2.40.1
Re: [PATCH 05/30] media: atomisp: Replace source-pad checks with run-mode checks
Quoted 27 lines · Hans de Goede
Currently atomisp behavior is determined by a mix of which /dev/video# node (which isp-subdev source-pad) is opened + which run-mode is set. With various combinations not being allowed and likely leading to crashes due to lack of error checking.
Now that we no longer support continuous mode and thus no longer support streaming from 2 /dev/video# nodes at the same time, there is no need to have a separate /dev/video# node for each run-mode. Instead the plan is to support the 3 different run-modes on a single /dev/video# node. Since we are moving to a single isp-subdev source-pad, the behavior should then be solely and consistently be defined by the run-mode.
Replace various source-pad checks with run-mode checks in preparation for moving to a single source-pad. In some places the new run-mode checks overlap with existing run-mode checks and the checks are folded together into a single check.
This removes handling of the
ATOMISP_SUBDEV_PAD_SOURCE_VFsource-pad, this source-pad was only useful for continuous mode, for which support has been removed.Note that currently the only run-mode which we actually have been able to get to work is the video-capture with scaler aka preview mode and as such that is also the only run-mode tested. This patch is intended to preserve the current (known to not work 100%) behavior of the other run-modes, so that those maybe can be enabled later.
...
Review static int atomisp_get_pipe_id(struct atomisp_video_pipe *pipe)
Quoted 1 line
(quoted diff) +0
-0@@ -5005,16 +4993,11 @@ static int atomisp_get_pipe_id(struct atomisp_video_pipe *pipe)
It seems to me that all 'else':s in this function are redundant. At least you can probably drop them either here or in a separate change.
Quoted 20 lines
drivers/staging/media/atomisp/pci/atomisp_cmd.c +4
-9return IA_CSS_PIPE_ID_VIDEO ; }else if (asd->vfpp->val ==ATOMISP_VFPP_DISABLE_LOWLAT ) {return IA_CSS_PIPE_ID_CAPTURE ; - }else if (pipe == &asd->video_out_video_capture) { + }else if (asd->run_mode->val ==ATOMISP_RUN_MODE_VIDEO ) {return IA_CSS_PIPE_ID_VIDEO ; - }else if (pipe == &asd->video_out_vf) { -return IA_CSS_PIPE_ID_CAPTURE ; - }else if (pipe == &asd->video_out_preview) { -if (asd->run_mode->val ==ATOMISP_RUN_MODE_VIDEO ) -return IA_CSS_PIPE_ID_VIDEO ; -else -return IA_CSS_PIPE_ID_PREVIEW ; - }else if (pipe == &asd->video_out_capture) { + }else if (asd->run_mode->val ==ATOMISP_RUN_MODE_PREVIEW ) { +return IA_CSS_PIPE_ID_PREVIEW ; + }else if (asd->run_mode->val ==ATOMISP_RUN_MODE_STILL_CAPTURE ) {if (asd->copy_mode)return IA_CSS_PIPE_ID_COPY ;else
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH 6/30 media: atomisp: Register only 1 /dev/video# node
In reply to Hans de GoedeNow that we no longer support continuous mode and thus no longer support streaming from 2 /dev/video# nodes at the same time, there is no need to have a separate /dev/video# node (+ matching v4l2-subdev pads) for each run-mode.
Keep the video_out_preview /dev/video0 device and remove the video_out_video_capture / video_out_video_vf / video_out_capture video-devices (atomisp_pipe-s) and also remove the matching ATOMISP_SUBDEV_PAD_SOURCE_VIDEO / ATOMISP_SUBDEV_PAD_SOURCE_VF / ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE source-pads.
--- .../staging/media/atomisp/pci/atomisp_cmd.c | 44 ++------ .../media/atomisp/pci/atomisp_compat_css20.c | 3 - .../staging/media/atomisp/pci/atomisp_fops.c | 92 +++------------- .../staging/media/atomisp/pci/atomisp_ioctl.c | 5 +- .../media/atomisp/pci/atomisp_subdev.c | 102 +----------------- .../media/atomisp/pci/atomisp_subdev.h | 15 +-- 6 files changed, 30 insertions(+), 231 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_cmd.c +10 -34
@@ -643,10 +643,7 @@ void atomisp_flush_video_pipe(struct atomisp_video_pipe *pipe, enum vb2_buffer_s/* Returns queued buffers back to video-core */ void atomisp_flush_bufs_and_wakeup (struct atomisp_sub_device *asd) { -atomisp_flush_video_pipe (&asd->video_out_capture,VB2_BUF_STATE_ERROR , false); -atomisp_flush_video_pipe (&asd->video_out_vf,VB2_BUF_STATE_ERROR , false);atomisp_flush_video_pipe (&asd->video_out_preview,VB2_BUF_STATE_ERROR , false); -atomisp_flush_video_pipe (&asd->video_out_video_capture,VB2_BUF_STATE_ERROR , false); }/* clean out the parameters that did not apply */
@@ -1035,9 +1032,7 @@ static void __atomisp_css_recover(struct atomisp_device *isp, bool isp_timeout)atomisp_flush_bufs_and_wakeup (&isp->asd);/* Requeue unprocessed per-frame parameters. */ -atomisp_recover_params_queue (&isp->asd.video_out_capture);atomisp_recover_params_queue (&isp->asd.video_out_preview); -atomisp_recover_params_queue (&isp->asd.video_out_video_capture); ret = v4l2_subdev_call( isp->inputs[isp->asd.input_curr].camera, video,
@@ -1298,7 +1293,7 @@ static void atomisp_update_capture_mode(struct atomisp_sub_device *asd)atomisp_css_capture_set_mode (asd,IA_CSS_CAPTURE_MODE_ADVANCED ); else if (asd->params.low_light) atomisp_css_capture_set_mode(asd, IA_CSS_CAPTURE_MODE_LOW_LIGHT); - else if (asd->video_out_capture.sh_fmt == IA_CSS_FRAME_FORMAT_RAW) + else if (asd->video_out_preview.sh_fmt == IA_CSS_FRAME_FORMAT_RAW) atomisp_css_capture_set_mode(asd, IA_CSS_CAPTURE_MODE_RAW); elseatomisp_css_capture_set_mode (asd ,IA_CSS_CAPTURE_MODE_PRIMARY );
@@ -4191,40 +4186,24 @@ static int atomisp_set_fmt_to_isp(struct video_device *vdev,* CSS still requires viewfinder configuration. */ { -struct v4l2_rect vf_size = {0 }; -struct v4l2_mbus_framefmt vf_ffmt = {0 }; +u32 width, height;if (pix->width <640 || pix->height <480 ) { - vf_size.width = pix->width; - vf_size.height = pix->height; + width = pix->width; + height = pix->height; }else { - vf_size.width =640 ; - vf_size.height =480 ; + width =640 ; + height =480 ; } -/* FIXME: proper format name for this one. See -atomisp_output_fmts[] in atomisp_v4l2.c */ - vf_ffmt.code =V4L2_MBUS_FMT_CUSTOM_YUV420 ; - -atomisp_subdev_set_selection (&asd->subdev, fh.state, -V4L2_SUBDEV_FORMAT_ACTIVE , -ATOMISP_SUBDEV_PAD_SOURCE_VF , -V4L2_SEL_TGT_COMPOSE ,0 , &vf_size); -atomisp_subdev_set_ffmt (&asd->subdev, fh.state, -V4L2_SUBDEV_FORMAT_ACTIVE , -ATOMISP_SUBDEV_PAD_SOURCE_VF , &vf_ffmt); - asd->video_out_vf.sh_fmt =IA_CSS_FRAME_FORMAT_NV12 ; -if (asd->run_mode->val ==ATOMISP_RUN_MODE_VIDEO || asd->vfpp->val ==ATOMISP_VFPP_DISABLE_SCALER ) { -atomisp_css_video_configure_viewfinder (asd, - vf_size.width, vf_size.height,0 , - asd->video_out_vf.sh_fmt); +atomisp_css_video_configure_viewfinder (asd, width, height,0 , +IA_CSS_FRAME_FORMAT_NV12 ); }else if (asd->run_mode->val ==ATOMISP_RUN_MODE_STILL_CAPTURE || asd->vfpp->val ==ATOMISP_VFPP_DISABLE_LOWLAT ) { -atomisp_css_capture_configure_viewfinder (asd, - vf_size.width, vf_size.height,0 , - asd->video_out_vf.sh_fmt); +atomisp_css_capture_configure_viewfinder (asd, width, height,0 , +IA_CSS_FRAME_FORMAT_NV12 ); } }
@@ -4811,9 +4790,6 @@ bool atomisp_is_vf_pipe(struct atomisp_video_pipe *pipe)return false; } -if (pipe == &asd->video_out_vf) -return true; -if (asd->run_mode->val ==ATOMISP_RUN_MODE_VIDEO && pipe == &asd->video_out_preview)return true;
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +0 -3
@@ -1958,10 +1958,7 @@ void atomisp_css_stop(struct atomisp_sub_device *asd,list_splice_init (&asd->metadata_ready[i], &asd->metadata[i]); } -atomisp_flush_params_queue (&asd->video_out_capture); -atomisp_flush_params_queue (&asd->video_out_vf);atomisp_flush_params_queue (&asd->video_out_preview); -atomisp_flush_params_queue (&asd->video_out_video_capture);atomisp_free_css_parameters (&asd->params.css_param);memset (&asd->params.css_param,0 ,sizeof (asd->params.css_param)); }
drivers/staging/media/atomisp/pci/atomisp_fops.c +13 -79
112 lines not on this page · raw message
drivers/staging/media/atomisp/pci/atomisp_ioctl.c +1 -4
@@ -618,10 +618,7 @@ static int atomisp_enum_input(struct file *file, void *fh,static unsigned int atomisp_subdev_streaming_count (struct atomisp_sub_device *asd) { -return vb2_start_streaming_called (&asd->video_out_preview.vb_queue) + -vb2_start_streaming_called (&asd->video_out_capture.vb_queue) + -vb2_start_streaming_called (&asd->video_out_video_capture.vb_queue) + -vb2_start_streaming_called (&asd->video_out_vf.vb_queue); +return vb2_start_streaming_called (&asd->video_out_preview.vb_queue); }unsigned int atomisp_streaming_count (struct atomisp_device *isp)
drivers/staging/media/atomisp/pci/atomisp_subdev.c +4 -98
175 lines not on this page · raw message
drivers/staging/media/atomisp/pci/atomisp_subdev.h +2 -13
@@ -32,15 +32,8 @@#define ATOMISP_MAX_EXP_ID (250)#define ATOMISP_SUBDEV_PAD_SINK 0 -/* capture output for still frames */ -#define ATOMISP_SUBDEV_PAD_SOURCE_CAPTURE 1 -/* viewfinder output for downscaled capture output */ -#define ATOMISP_SUBDEV_PAD_SOURCE_VF 2 -/* preview output for display */ -#define ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW 3 -/* main output for video pipeline */ -#define ATOMISP_SUBDEV_PAD_SOURCE_VIDEO 4 -#define ATOMISP_SUBDEV_PADS_NUM 5 +#define ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW 1 +#define ATOMISP_SUBDEV_PADS_NUM 2struct atomisp_in_fmt_conv {u32 code;
@@ -251,11 +244,7 @@ struct atomisp_sub_device {u16 capture_pad;/* main capture pad; defines much of isp config */ unsigned int output; -struct atomisp_video_pipe video_out_capture;/* capture output */ -struct atomisp_video_pipe video_out_vf;/* viewfinder output */ struct atomisp_video_pipe video_out_preview;/* preview output */ -/* video pipe main output */ -struct atomisp_video_pipe video_out_video_capture;/* struct isp_subdev_params params; */ struct atomisp_device *isp;struct v4l2_ctrl_handler ctrl_handler;
Signature · 1 line
2.40.1
Re: [PATCH 06/30] media: atomisp: Register only 1 /dev/video# node
Quoted 9 lines · Hans de Goede
Now that we no longer support continuous mode and thus no longer support streaming from 2 /dev/video# nodes at the same time, there is no need to have a separate /dev/video# node (+ matching v4l2-subdev pads) for each run-mode.
Keep the
video_out_preview/dev/video0device and removethe
video_out_video_capture/video_out_video_vf/video_out_capture
video_out_vf I assume.
Quoted 3 lines
video-devices (atomisp_pipe-s) and also remove the matching
ATOMISP_SUBDEV_PAD_SOURCE_VIDEO/ATOMISP_SUBDEV_PAD_SOURCE_VF/ATOMISP_SUBDEV_PAD_SOURCE_CAPTUREsource-pads.
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH 7/30 media: atomisp: Drop atomisp_is_vf_pipe()
In reply to Hans de GoedeSince there only is one /dev/video# node now (no more continuous mode), there are now no longer separate main capture + view-finder pipes.
We are now always on the main pipe, so atomisp_is_vf_pipe() should always return false now. Drop any checks using it, replacing them with the code-path for a false return.
--- .../staging/media/atomisp/pci/atomisp_cmd.c | 32 ++----------------- .../staging/media/atomisp/pci/atomisp_cmd.h | 2 -- .../staging/media/atomisp/pci/atomisp_fops.c | 5 ++- .../staging/media/atomisp/pci/atomisp_ioctl.c | 3 +- 4 files changed, 5 insertions(+), 37 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_cmd.c +2 -30
@@ -3216,9 +3216,6 @@ void atomisp_handle_parameter_and_buffer(struct atomisp_video_pipe *pipe)lockdep_assert_held (&asd->isp->mutex); -if (atomisp_is_vf_pipe (pipe)) -return ; -/* * CSS/FW requires set parameter and enqueue buffer happen after ISP * is streamon.
@@ -3294,15 +3291,7 @@ int atomisp_set_parameters(struct video_device *vdev,dev_dbg (asd->isp->dev,"set parameter(per_frame_setting %d) isp_config_id %d of %s\n" , arg->per_frame_setting, arg->isp_config_id, vdev->name); -if (IS_ISP2401 ) { -if (atomisp_is_vf_pipe (pipe) && arg->per_frame_setting) { -dev_err (asd->isp->dev,"%s: vf pipe not support per_frame_setting" , - __func__); -return -EINVAL ; - } - } - -if (arg->per_frame_setting && !atomisp_is_vf_pipe (pipe)) { +if (arg->per_frame_setting) {/* * Per-frame setting enabled, we allocate a new parameter * buffer to cache the parameters and only when frame buffers
@@ -3341,7 +3330,7 @@ int atomisp_set_parameters(struct video_device *vdev,if (ret) goto apply_parameter_failed; -if (!(arg->per_frame_setting && !atomisp_is_vf_pipe (pipe))) { +if (!arg->per_frame_setting) {/* indicate to CSS that we have parameters to be updated */ asd->params.css_update_params_needed = true; }else {
@@ -4780,23 +4769,6 @@ int atomisp_flash_enable(struct atomisp_sub_device *asd, int num_frames)return 0 ; } -bool atomisp_is_vf_pipe (struct atomisp_video_pipe *pipe) -{ -struct atomisp_sub_device *asd = pipe->asd; - -if (!asd) { -dev_err (pipe->isp->dev,"%s(): asd is NULL, device is %s\n" , - __func__, pipe->vdev.name); -return false; - } - -if (asd->run_mode->val ==ATOMISP_RUN_MODE_VIDEO && - pipe == &asd->video_out_preview) -return true; - -return false; -} -static int __checking_exp_id (struct atomisp_sub_device *asd,int exp_id) {struct atomisp_device *isp = asd->isp;
drivers/staging/media/atomisp/pci/atomisp_cmd.h +0 -2
@@ -291,8 +291,6 @@ void atomisp_eof_event(struct atomisp_sub_device *asd, uint8_t exp_id);enum mipi_port_id __get_mipi_port (struct atomisp_device *isp,enum atomisp_camera_port port); -bool atomisp_is_vf_pipe (struct atomisp_video_pipe *pipe); -void atomisp_apply_css_parameters (struct atomisp_sub_device *asd,struct atomisp_css_params *css_param);
drivers/staging/media/atomisp/pci/atomisp_fops.c +2 -3
@@ -403,9 +403,8 @@ static void atomisp_buf_queue(struct vb2_buffer *vb)* is put to waiting list until previous per-frame parameter buffers * get enqueued. */ -if (!atomisp_is_vf_pipe (pipe) && - (pipe->frame_request_config_id[vb->index] || - !list_empty (&pipe->buffers_waiting_for_param))) +if (pipe->frame_request_config_id[vb->index] || + !list_empty (&pipe->buffers_waiting_for_param))list_add_tail (&frame->queue, &pipe->buffers_waiting_for_param);else list_add_tail (&frame->queue, &pipe->activeq);
drivers/staging/media/atomisp/pci/atomisp_ioctl.c +1 -2
@@ -1045,8 +1045,7 @@ static int atomisp_qbuf_wrapper(struct file *file, void *fh, struct v4l2_bufferif (buf->index >= vdev->queue->num_buffers)return -EINVAL ; -if (!atomisp_is_vf_pipe (pipe) && - (buf->reserved2 &ATOMISP_BUFFER_HAS_PER_FRAME_SETTING )) { +if (buf->reserved2 &ATOMISP_BUFFER_HAS_PER_FRAME_SETTING ) {/* this buffer will have a per-frame parameter */ pipe->frame_request_config_id[buf->index] = buf->reserved2 & ~ATOMISP_BUFFER_HAS_PER_FRAME_SETTING ;
Signature · 1 line
2.40.1
Re: [PATCH 07/30] media: atomisp: Drop atomisp_is_vf_pipe()
Quoted 7 lines · Hans de Goede
Since there only is one /dev/video# node now (no more continuous mode), there are now no longer separate main capture + view-finder pipes.
We are now always on the main pipe, so
atomisp_is_vf_pipe()should always return false now. Drop any checks using it, replacing them with the code-path for a false return.
...
Quoted 4 lines
+ if (
arg->per_frame_setting) {
/*
* Per-frame setting enabled, we allocate a new parameter
* buffer to cache the parameters and only when frame buffers
...
drivers/staging/media/atomisp/pci/atomisp_cmd.c int atomisp_set_parameters(struct video_device *vdev, · line 3333
Quoted 2 lines
drivers/staging/media/atomisp/pci/atomisp_cmd.c +1
-1-if (!(arg->per_frame_setting && !atomisp_is_vf_pipe (pipe))) { +if (!arg->per_frame_setting) {
I'm wondering if we can make the conditional positive as in the above chunk, so the below will go to the else branch. It might be that both of them can be united (haven't checked the full context though).
Quoted 3 lines
/* indicate to CSS that we have parameters to be updated */
asd->params.css_update_params_needed = true;
} else {Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH 8/30 media: atomisp: Rename video_out_preview to video_out
In reply to Hans de GoedeNow that we have only 1 /dev/video# node for output for all different run-modes (with only 1 run-mode at a time) using video_out_preview for the remaining atomisp_pipe does not properly reflect that this is *the* output pipe. Fo the following renames to fix the naming:
s/video_out_preview/video_out/ s/ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW/ATOMISP_SUBDEV_PAD_SOURCE/
--- .../staging/media/atomisp/pci/atomisp_cmd.c | 6 ++-- .../media/atomisp/pci/atomisp_compat_css20.c | 2 +- .../staging/media/atomisp/pci/atomisp_fops.c | 4 +-- .../staging/media/atomisp/pci/atomisp_ioctl.c | 2 +- .../media/atomisp/pci/atomisp_subdev.c | 34 ++++++++----------- .../media/atomisp/pci/atomisp_subdev.h | 5 ++- 6 files changed, 23 insertions(+), 30 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_cmd.c +3 -3
@@ -643,7 +643,7 @@ void atomisp_flush_video_pipe(struct atomisp_video_pipe *pipe, enum vb2_buffer_s/* Returns queued buffers back to video-core */ void atomisp_flush_bufs_and_wakeup (struct atomisp_sub_device *asd) { -atomisp_flush_video_pipe (&asd->video_out_preview,VB2_BUF_STATE_ERROR , false); +atomisp_flush_video_pipe (&asd->video_out,VB2_BUF_STATE_ERROR , false); }/* clean out the parameters that did not apply */
@@ -1032,7 +1032,7 @@ static void __atomisp_css_recover(struct atomisp_device *isp, bool isp_timeout)atomisp_flush_bufs_and_wakeup (&isp->asd);/* Requeue unprocessed per-frame parameters. */ -atomisp_recover_params_queue (&isp->asd.video_out_preview); +atomisp_recover_params_queue (&isp->asd.video_out); ret = v4l2_subdev_call( isp->inputs[isp->asd.input_curr].camera, video,
@@ -1293,7 +1293,7 @@ static void atomisp_update_capture_mode(struct atomisp_sub_device *asd)atomisp_css_capture_set_mode (asd,IA_CSS_CAPTURE_MODE_ADVANCED ); else if (asd->params.low_light) atomisp_css_capture_set_mode(asd, IA_CSS_CAPTURE_MODE_LOW_LIGHT); - else if (asd->video_out_preview.sh_fmt == IA_CSS_FRAME_FORMAT_RAW) + else if (asd->video_out.sh_fmt == IA_CSS_FRAME_FORMAT_RAW) atomisp_css_capture_set_mode(asd, IA_CSS_CAPTURE_MODE_RAW); elseatomisp_css_capture_set_mode (asd ,IA_CSS_CAPTURE_MODE_PRIMARY );
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +1 -1
@@ -1958,7 +1958,7 @@ void atomisp_css_stop(struct atomisp_sub_device *asd,list_splice_init (&asd->metadata_ready[i], &asd->metadata[i]); } -atomisp_flush_params_queue (&asd->video_out_preview); +atomisp_flush_params_queue (&asd->video_out);atomisp_free_css_parameters (&asd->params.css_param);memset (&asd->params.css_param,0 ,sizeof (asd->params.css_param)); }
drivers/staging/media/atomisp/pci/atomisp_fops.c +2 -2
@@ -362,7 +362,7 @@ int atomisp_qbuffers_to_css(struct atomisp_sub_device *asd) pipe_id =IA_CSS_PIPE_ID_CAPTURE ; } -atomisp_q_video_buffers_to_css (asd, &asd->video_out_preview, +atomisp_q_video_buffers_to_css (asd, &asd->video_out,ATOMISP_INPUT_STREAM_GENERAL ,IA_CSS_BUFFER_TYPE_OUTPUT_FRAME , pipe_id);return 0 ;
@@ -494,7 +494,7 @@ static void atomisp_subdev_init_struct(struct atomisp_sub_device *asd)*/ static unsigned int atomisp_subdev_users (struct atomisp_sub_device *asd) { -return asd->video_out_preview.users; +return asd->video_out.users; }unsigned int atomisp_dev_users (struct atomisp_device *isp)
drivers/staging/media/atomisp/pci/atomisp_ioctl.c +1 -1
@@ -618,7 +618,7 @@ static int atomisp_enum_input(struct file *file, void *fh,static unsigned int atomisp_subdev_streaming_count (struct atomisp_sub_device *asd) { -return vb2_start_streaming_called (&asd->video_out_preview.vb_queue); +return vb2_start_streaming_called (&asd->video_out.vb_queue); }unsigned int atomisp_streaming_count (struct atomisp_device *isp)
drivers/staging/media/atomisp/pci/atomisp_subdev.c +14 -20
@@ -355,7 +355,7 @@ static const char *atomisp_pad_str(unsigned int pad) {static const char *const pad_str[] = {"ATOMISP_SUBDEV_PAD_SINK" , -"ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW" , +"ATOMISP_SUBDEV_PAD_SOURCE" , };if (pad >=ARRAY_SIZE (pad_str))
@@ -431,7 +431,7 @@ int atomisp_subdev_set_selection(struct v4l2_subdev *sd,struct v4l2_rect tmp = *crop[pad];atomisp_subdev_set_selection (sd, sd_state, which, -ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW , +ATOMISP_SUBDEV_PAD_SOURCE ,V4L2_SEL_TGT_COMPOSE , flags, &tmp); }
@@ -593,7 +593,7 @@ void atomisp_subdev_set_ffmt(struct v4l2_subdev *sd,break ; } -case ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW : +case ATOMISP_SUBDEV_PAD_SOURCE : __ffmt->code = ffmt->code;break ; }
@@ -900,12 +900,10 @@ static int isp_subdev_init_entities(struct atomisp_sub_device *asd) sd->flags |=V4L2_SUBDEV_FL_HAS_EVENTS |V4L2_SUBDEV_FL_HAS_DEVNODE ; pads[ATOMISP_SUBDEV_PAD_SINK ].flags =MEDIA_PAD_FL_SINK ; - pads[ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW ].flags =MEDIA_PAD_FL_SOURCE ; + pads[ATOMISP_SUBDEV_PAD_SOURCE ].flags =MEDIA_PAD_FL_SOURCE ; - asd->fmt[ATOMISP_SUBDEV_PAD_SINK ].fmt.code = -MEDIA_BUS_FMT_SBGGR10_1X10 ; - asd->fmt[ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW ].fmt.code = -MEDIA_BUS_FMT_SBGGR10_1X10 ; + asd->fmt[ATOMISP_SUBDEV_PAD_SINK ].fmt.code =MEDIA_BUS_FMT_SBGGR10_1X10 ; + asd->fmt[ATOMISP_SUBDEV_PAD_SOURCE ].fmt.code =MEDIA_BUS_FMT_SBGGR10_1X10 ; me->ops = &isp_subdev_media_ops; me->function =MEDIA_ENT_F_PROC_VIDEO_ISP ;
@@ -913,13 +911,11 @@ static int isp_subdev_init_entities(struct atomisp_sub_device *asd)if (ret <0 )return ret; - ret =atomisp_init_subdev_pipe (asd, &asd->video_out_preview, -V4L2_BUF_TYPE_VIDEO_CAPTURE ); + ret =atomisp_init_subdev_pipe (asd, &asd->video_out,V4L2_BUF_TYPE_VIDEO_CAPTURE );if (ret)return ret; - ret =atomisp_video_init (&asd->video_out_preview,"PREVIEW" , -ATOMISP_RUN_MODE_PREVIEW ); + ret =atomisp_video_init (&asd->video_out,"PREVIEW" ,ATOMISP_RUN_MODE_PREVIEW );if (ret <0 )return ret;
@@ -981,9 +977,8 @@ int atomisp_create_pads_links(struct atomisp_device *isp)return ret; } - ret =media_create_pad_link (&isp->asd.subdev.entity, -ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW , - &isp->asd.video_out_preview.vdev.entity,0 ,0 ); + ret =media_create_pad_link (&isp->asd.subdev.entity,ATOMISP_SUBDEV_PAD_SOURCE , + &isp->asd.video_out.vdev.entity,0 ,0 );if (ret <0 )return ret;
@@ -1015,7 +1010,7 @@ void atomisp_subdev_unregister_entities(struct atomisp_sub_device *asd) {atomisp_subdev_cleanup_entities (asd);v4l2_device_unregister_subdev (&asd->subdev); -atomisp_video_unregister (&asd->video_out_preview); +atomisp_video_unregister (&asd->video_out); } int atomisp_subdev_register_subdev(struct atomisp_sub_device *asd,
@@ -1029,10 +1024,9 @@ int atomisp_subdev_register_video_nodes(struct atomisp_sub_device *asd, {int ret; - asd->video_out_preview.vdev.v4l2_dev = vdev; - asd->video_out_preview.vdev.device_caps =V4L2_CAP_VIDEO_CAPTURE |V4L2_CAP_STREAMING ; - ret =video_register_device (&asd->video_out_preview.vdev, -VFL_TYPE_VIDEO ,-1 ); + asd->video_out.vdev.v4l2_dev = vdev; + asd->video_out.vdev.device_caps =V4L2_CAP_VIDEO_CAPTURE |V4L2_CAP_STREAMING ; + ret =video_register_device (&asd->video_out.vdev,VFL_TYPE_VIDEO ,-1 );if (ret <0 ) goto error;
drivers/staging/media/atomisp/pci/atomisp_subdev.h +2 -3
@@ -32,7 +32,7 @@#define ATOMISP_MAX_EXP_ID (250)#define ATOMISP_SUBDEV_PAD_SINK 0 -#define ATOMISP_SUBDEV_PAD_SOURCE_PREVIEW 1 +#define ATOMISP_SUBDEV_PAD_SOURCE 1#define ATOMISP_SUBDEV_PADS_NUM 2struct atomisp_in_fmt_conv {
@@ -244,8 +244,7 @@ struct atomisp_sub_device {u16 capture_pad;/* main capture pad; defines much of isp config */ unsigned int output; -struct atomisp_video_pipe video_out_preview;/* preview output */ -/* struct isp_subdev_params params; */ +struct atomisp_video_pipe video_out;struct atomisp_device *isp;struct v4l2_ctrl_handler ctrl_handler;struct v4l2_ctrl *run_mode;
Signature · 1 line
2.40.1
PATCH 9/30 media: atomisp: Remove source_pad parameter from functions and structs
In reply to Hans de GoedeNow that there is only 1 source-pad for an asd there is no need to have a parameter for this in various places.
Remove the source_pad function parameter and
atomisp_sub_device.capture_pad data member.
--- .../staging/media/atomisp/pci/atomisp_cmd.c | 44 ++++++++----------- .../media/atomisp/pci/atomisp_compat.h | 4 +- .../media/atomisp/pci/atomisp_compat_css20.c | 4 +- .../staging/media/atomisp/pci/atomisp_fops.c | 7 ++- .../staging/media/atomisp/pci/atomisp_ioctl.c | 13 +++--- .../media/atomisp/pci/atomisp_subdev.c | 25 ++--------- .../media/atomisp/pci/atomisp_subdev.h | 5 +-- 7 files changed, 33 insertions(+), 69 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_cmd.c +18 -26
@@ -229,8 +229,8 @@ int atomisp_freq_scaling(struct atomisp_device *isp, goto done; } - curr_rules.width = isp->asd.fmt[isp->asd.capture_pad].fmt.width; - curr_rules.height = isp->asd.fmt[isp->asd.capture_pad].fmt.height; + curr_rules.width = isp->asd.fmt[ATOMISP_SUBDEV_PAD_SOURCE ].fmt.width; + curr_rules.height = isp->asd.fmt[ATOMISP_SUBDEV_PAD_SOURCE ].fmt.height; curr_rules.fps = fps; curr_rules.run_mode = isp->asd.run_mode->val;
@@ -1548,13 +1548,12 @@ void atomisp_free_internal_buffers(struct atomisp_sub_device *asd) }static void atomisp_update_grid_info (struct atomisp_sub_device *asd, -enum ia_css_pipe_id pipe_id, -int source_pad) +enum ia_css_pipe_id pipe_id) {struct atomisp_device *isp = asd->isp;int err; -if (atomisp_css_get_grid_info (asd, pipe_id, source_pad)) +if (atomisp_css_get_grid_info (asd, pipe_id))return ;/* We must free all buffers because they no longer match
@@ -4105,8 +4104,7 @@ static int css_input_resolution_changed(struct atomisp_sub_device *asd,static int atomisp_set_fmt_to_isp (struct video_device *vdev,struct ia_css_frame_info *output_info, -struct v4l2_pix_format *pix, -unsigned int source_pad) +struct v4l2_pix_format *pix) {struct camera_mipi_info *mipi_info;struct atomisp_device *isp =video_get_drvdata (vdev);
@@ -4279,7 +4277,7 @@ static int atomisp_set_fmt_to_isp(struct video_device *vdev,return ret; } -atomisp_update_grid_info (asd, pipe_id, source_pad); +atomisp_update_grid_info (asd, pipe_id);return 0 ; }
@@ -4303,7 +4301,7 @@ static void atomisp_get_dis_envelop(struct atomisp_sub_device *asd, }static void atomisp_check_copy_mode (struct atomisp_sub_device *asd, -int source_pad,const struct v4l2_pix_format *f) +const struct v4l2_pix_format *f) {struct v4l2_mbus_framefmt *sink, *src;
@@ -4316,7 +4314,7 @@ static void atomisp_check_copy_mode(struct atomisp_sub_device *asd, sink =atomisp_subdev_get_ffmt (&asd->subdev,NULL ,V4L2_SUBDEV_FORMAT_ACTIVE ,ATOMISP_SUBDEV_PAD_SINK ); src =atomisp_subdev_get_ffmt (&asd->subdev,NULL , -V4L2_SUBDEV_FORMAT_ACTIVE , source_pad); +V4L2_SUBDEV_FORMAT_ACTIVE ,ATOMISP_SUBDEV_PAD_SOURCE );if (sink->code == src->code && sink->width == f->width && sink->height == f->height) asd->copy_mode = true;
@@ -4439,7 +4437,6 @@ int atomisp_set_fmt(struct video_device *vdev, struct v4l2_format *f) .which = V4L2_SUBDEV_FORMAT_ACTIVE, };struct v4l2_rect isp_sink_crop; -u16 source_pad =atomisp_subdev_source_pad (vdev);struct v4l2_subdev_fh fh;int ret;
@@ -4447,12 +4444,9 @@ int atomisp_set_fmt(struct video_device *vdev, struct v4l2_format *f)if (ret)return ret; -if (source_pad >=ATOMISP_SUBDEV_PADS_NUM ) -return -EINVAL ; -dev_dbg (isp->dev, -"setting resolution %ux%u on pad %u bytesperline %u\n" , - f->fmt.pix.width, f->fmt.pix.height, source_pad, f->fmt.pix.bytesperline); +"setting resolution %ux%u bytesperline %u\n" , + f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.bytesperline);v4l2_fh_init (&fh.vfh, vdev);
@@ -4501,9 +4495,9 @@ int atomisp_set_fmt(struct video_device *vdev, struct v4l2_format *f) isp_source_fmt.code = format_bridge->mbus_code;atomisp_subdev_set_ffmt (&asd->subdev, fh.state,V4L2_SUBDEV_FORMAT_ACTIVE , - source_pad, &isp_source_fmt); +ATOMISP_SUBDEV_PAD_SOURCE , &isp_source_fmt); -if (!atomisp_subdev_format_conversion (asd, source_pad)) { +if (!atomisp_subdev_format_conversion (asd)) { padding_w =0 ; padding_h =0 ; }
@@ -4511,8 +4505,6 @@ int atomisp_set_fmt(struct video_device *vdev, struct v4l2_format *f)atomisp_get_dis_envelop (asd, f->fmt.pix.width, f->fmt.pix.height, &dvs_env_w, &dvs_env_h); - asd->capture_pad = source_pad; - ret =atomisp_set_fmt_to_snr (vdev, &f->fmt.pix, padding_w, padding_h, dvs_env_w, dvs_env_h);if (ret) {
@@ -4523,7 +4515,7 @@ int atomisp_set_fmt(struct video_device *vdev, struct v4l2_format *f)atomisp_csi_lane_config (isp); -atomisp_check_copy_mode (asd, source_pad, &f->fmt.pix); +atomisp_check_copy_mode (asd, &f->fmt.pix); isp_sink_crop = *atomisp_subdev_get_rect(&asd->subdev, NULL, V4L2_SUBDEV_FORMAT_ACTIVE,
@@ -4534,7 +4526,7 @@ int atomisp_set_fmt(struct video_device *vdev, struct v4l2_format *f)* width or height) bigger than the desired result. */ if (isp_sink_crop.width *9 /10 < f->fmt.pix.width || isp_sink_crop.height *9 /10 < f->fmt.pix.height || - (atomisp_subdev_format_conversion (asd, source_pad) && + (atomisp_subdev_format_conversion (asd) && (asd->run_mode->val ==ATOMISP_RUN_MODE_VIDEO || asd->vfpp->val ==ATOMISP_VFPP_DISABLE_SCALER ))) { isp_sink_crop.width = f->fmt.pix.width;
@@ -4548,7 +4540,7 @@ int atomisp_set_fmt(struct video_device *vdev, struct v4l2_format *f) &isp_sink_crop);atomisp_subdev_set_selection (&asd->subdev, fh.state,V4L2_SUBDEV_FORMAT_ACTIVE , - source_pad,V4L2_SEL_TGT_COMPOSE , +ATOMISP_SUBDEV_PAD_SOURCE ,V4L2_SEL_TGT_COMPOSE ,0 , &isp_sink_crop); }else if (IS_MOFD ) {struct v4l2_rect main_compose = {0 };
@@ -4567,7 +4559,7 @@ int atomisp_set_fmt(struct video_device *vdev, struct v4l2_format *f)atomisp_subdev_set_selection (&asd->subdev, fh.state,V4L2_SUBDEV_FORMAT_ACTIVE , - source_pad, +ATOMISP_SUBDEV_PAD_SOURCE ,V4L2_SEL_TGT_COMPOSE ,0 , &main_compose); }else {
@@ -4605,12 +4597,12 @@ int atomisp_set_fmt(struct video_device *vdev, struct v4l2_format *f)atomisp_subdev_set_selection (&asd->subdev, fh.state,V4L2_SUBDEV_FORMAT_ACTIVE , - source_pad, +ATOMISP_SUBDEV_PAD_SOURCE ,V4L2_SEL_TGT_COMPOSE ,0 , &main_compose); } - ret =atomisp_set_fmt_to_isp (vdev, &output_info, &f->fmt.pix, source_pad); + ret =atomisp_set_fmt_to_isp (vdev, &output_info, &f->fmt.pix);if (ret) {dev_warn (isp->dev,"Can't set format on ISP. Error %d\n" , ret);return -EINVAL ;
drivers/staging/media/atomisp/pci/atomisp_compat.h +1 -3
@@ -113,8 +113,7 @@ void atomisp_css_free_metadata_buffer(struct atomisp_metadata_buf *metadata_buf);int atomisp_css_get_grid_info (struct atomisp_sub_device *asd, -enum ia_css_pipe_id pipe_id, -int source_pad); +enum ia_css_pipe_id pipe_id);int atomisp_alloc_3a_output_buf (struct atomisp_sub_device *asd);
@@ -276,7 +275,6 @@ int atomisp_css_video_configure_output(struct atomisp_sub_device *asd, enum ia_css_frame_format format);int atomisp_get_css_frame_info (struct atomisp_sub_device *asd, -u16 source_pad,struct ia_css_frame_info *frame_info); int atomisp_css_video_configure_viewfinder(struct atomisp_sub_device *asd,
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +1 -3
@@ -1328,8 +1328,7 @@ void atomisp_css_free_stat_buffers(struct atomisp_sub_device *asd) }int atomisp_css_get_grid_info (struct atomisp_sub_device *asd, -enum ia_css_pipe_id pipe_id, -int source_pad) +enum ia_css_pipe_id pipe_id) {struct ia_css_pipe_info p_info;struct ia_css_grid_info old_info;
@@ -2432,7 +2431,6 @@ static unsigned int atomisp_get_pipe_index(struct atomisp_sub_device *asd) }int atomisp_get_css_frame_info (struct atomisp_sub_device *asd, -u16 source_pad,struct ia_css_frame_info *frame_info) {struct ia_css_pipe_info info;
drivers/staging/media/atomisp/pci/atomisp_fops.c +3 -4
@@ -47,7 +47,6 @@ static int atomisp_queue_setup(struct vb2_queue *vq, unsigned int sizes[], struct device *alloc_devs[]) { struct atomisp_video_pipe *pipe = container_of(vq, struct atomisp_video_pipe, vb_queue); -u16 source_pad =atomisp_subdev_source_pad (&pipe->vdev);int ret;mutex_lock (&pipe->asd->isp->mutex);/* for get_css_frame_info() / set_fmt() */
@@ -56,7 +55,7 @@ static int atomisp_queue_setup(struct vb2_queue *vq,* When VIDIOC_S_FMT has not been called before VIDIOC_REQBUFS, then * this will fail. Call atomisp_set_fmt() ourselves and try again. */ - ret =atomisp_get_css_frame_info (pipe->asd, source_pad, &pipe->frame_info); + ret =atomisp_get_css_frame_info (pipe->asd, &pipe->frame_info);if (ret) {struct v4l2_format f = { .fmt.pix.pixelformat =V4L2_PIX_FMT_YUV420 ,
@@ -68,7 +67,7 @@ static int atomisp_queue_setup(struct vb2_queue *vq,if (ret) goto out; - ret =atomisp_get_css_frame_info (pipe->asd, source_pad, &pipe->frame_info); + ret =atomisp_get_css_frame_info (pipe->asd, &pipe->frame_info);if (ret) goto out; }
@@ -654,7 +653,7 @@ static int atomisp_release(struct file *file) done:atomisp_subdev_set_selection (&asd->subdev, fh.state,V4L2_SUBDEV_FORMAT_ACTIVE , -atomisp_subdev_source_pad (vdev), +ATOMISP_SUBDEV_PAD_SOURCE ,V4L2_SEL_TGT_COMPOSE ,0 , &clear_compose);mutex_unlock (&isp->mutex);
drivers/staging/media/atomisp/pci/atomisp_ioctl.c +5 -8
@@ -1131,7 +1131,7 @@ static unsigned int atomisp_sensor_start_stream(struct atomisp_sub_device *asd)if (asd->run_mode->val ==ATOMISP_RUN_MODE_VIDEO || (asd->run_mode->val ==ATOMISP_RUN_MODE_STILL_CAPTURE && - !atomisp_is_mbuscode_raw (asd->fmt[asd->capture_pad].fmt.code))) + !atomisp_is_mbuscode_raw (asd->fmt[ATOMISP_SUBDEV_PAD_SOURCE ].fmt.code)))return 2 ;else return 1 ;
@@ -1159,7 +1159,6 @@ int atomisp_start_streaming(struct vb2_queue *vq, unsigned int count) {struct atomisp_video_pipe *pipe =vq_to_pipe (vq);struct atomisp_sub_device *asd = pipe->asd; -struct video_device *vdev = &pipe->vdev;struct atomisp_device *isp = asd->isp;struct pci_dev *pdev =to_pci_dev (isp->dev);enum ia_css_pipe_id css_pipe_id;
@@ -1167,9 +1166,9 @@ int atomisp_start_streaming(struct vb2_queue *vq, unsigned int count)unsigned long irqflags;int ret; -mutex_lock (&isp->mutex); +dev_dbg (isp->dev,"Start stream\n" ); -dev_dbg (isp->dev,"Start stream on pad %d\n" ,atomisp_subdev_source_pad (vdev)); +mutex_lock (&isp->mutex); ret =atomisp_pipe_check (pipe, false);if (ret)
@@ -1291,7 +1290,6 @@ void atomisp_stop_streaming(struct vb2_queue *vq) {struct atomisp_video_pipe *pipe =vq_to_pipe (vq);struct atomisp_sub_device *asd = pipe->asd; -struct video_device *vdev = &pipe->vdev;struct atomisp_device *isp = asd->isp;struct pci_dev *pdev =to_pci_dev (isp->dev);enum ia_css_pipe_id css_pipe_id;
@@ -1300,10 +1298,9 @@ void atomisp_stop_streaming(struct vb2_queue *vq)unsigned long flags;int ret; +dev_dbg (isp->dev,"Stop stream\n" ); +mutex_lock (&isp->mutex); - -dev_dbg (isp->dev,"Stop stream on pad %d\n" ,atomisp_subdev_source_pad (vdev)); -/* * There is no guarantee that the buffers queued to / owned by the ISP * will properly be returned to the queue when stopping. Set a flag to
drivers/staging/media/atomisp/pci/atomisp_subdev.c +4 -21
@@ -117,35 +117,19 @@ const struct atomisp_in_fmt_conv *atomisp_find_in_fmt_conv_by_atomisp_in_fmt(return NULL ; } -bool atomisp_subdev_format_conversion (struct atomisp_sub_device *asd, -unsigned int source_pad) +bool atomisp_subdev_format_conversion (struct atomisp_sub_device *asd) {struct v4l2_mbus_framefmt *sink, *src; sink =atomisp_subdev_get_ffmt (&asd->subdev,NULL , -V4L2_SUBDEV_FORMAT_ACTIVE , -ATOMISP_SUBDEV_PAD_SINK ); +V4L2_SUBDEV_FORMAT_ACTIVE ,ATOMISP_SUBDEV_PAD_SINK ); src =atomisp_subdev_get_ffmt (&asd->subdev,NULL , -V4L2_SUBDEV_FORMAT_ACTIVE , source_pad); +V4L2_SUBDEV_FORMAT_ACTIVE ,ATOMISP_SUBDEV_PAD_SOURCE );return atomisp_is_mbuscode_raw (sink->code) && !atomisp_is_mbuscode_raw (src->code); } -uint16_t atomisp_subdev_source_pad (struct video_device *vdev) -{ -struct media_link *link; -u16 ret =0 ; - -list_for_each_entry (link, &vdev->entity.links, list) { -if (link->source) { - ret = link->source->index; -break ; - } - } -return ret; -} -/* * V4L2 subdev operations */
@@ -404,8 +388,7 @@ int atomisp_subdev_set_selection(struct v4l2_subdev *sd, padding_h =12 ; } -if (atomisp_subdev_format_conversion (isp_sd, - isp_sd->capture_pad) +if (atomisp_subdev_format_conversion (isp_sd) && crop[pad]->width && crop[pad]->height) { crop[pad]->width -= padding_w; crop[pad]->height -= padding_h;
drivers/staging/media/atomisp/pci/atomisp_subdev.h +1 -4
@@ -241,7 +241,6 @@ struct atomisp_sub_device {struct v4l2_subdev subdev;struct media_pad pads[ATOMISP_SUBDEV_PADS_NUM ];struct atomisp_pad_format fmt[ATOMISP_SUBDEV_PADS_NUM ]; -u16 capture_pad;/* main capture pad; defines much of isp config */ unsigned int output;struct atomisp_video_pipe video_out;
@@ -340,9 +339,7 @@ const struct atomisp_in_fmt_conv atomisp_in_fmt);const struct atomisp_in_fmt_conv *atomisp_find_in_fmt_conv_compressed (u32 code); -bool atomisp_subdev_format_conversion (struct atomisp_sub_device *asd, -unsigned int source_pad); -uint16_t atomisp_subdev_source_pad (struct video_device *vdev); +bool atomisp_subdev_format_conversion (struct atomisp_sub_device *asd);/* Get pointer to appropriate format */ struct v4l2_mbus_framefmt
Signature · 1 line
2.40.1
PATCH 10/30 media: atomisp: Remove 1 line atomisp_flush_bufs_and_wakeup() helper
In reply to Hans de GoedeAfter recent changes this now is just a wrapper around atomisp_flush_video_pipe(). Make its single caller call atomisp_flush_video_pipe() directly and drop the helper.
--- drivers/staging/media/atomisp/pci/atomisp_cmd.c | 8 +------- drivers/staging/media/atomisp/pci/atomisp_cmd.h | 1 - 2 files changed, 1 insertion(+), 8 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_cmd.c +1 -7
@@ -640,12 +640,6 @@ void atomisp_flush_video_pipe(struct atomisp_video_pipe *pipe, enum vb2_buffer_sspin_unlock_irqrestore (&pipe->irq_lock, irqflags); } -/* Returns queued buffers back to video-core */ -void atomisp_flush_bufs_and_wakeup (struct atomisp_sub_device *asd) -{ -atomisp_flush_video_pipe (&asd->video_out,VB2_BUF_STATE_ERROR , false); -} -/* clean out the parameters that did not apply */ void atomisp_flush_params_queue (struct atomisp_video_pipe *pipe) {
@@ -1029,7 +1023,7 @@ static void __atomisp_css_recover(struct atomisp_device *isp, bool isp_timeout)* dequeueing buffers is not needed. CSS will recycle * buffers that it has. */ -atomisp_flush_bufs_and_wakeup (&isp->asd); +atomisp_flush_video_pipe (&isp->asd.video_out,VB2_BUF_STATE_ERROR , false);/* Requeue unprocessed per-frame parameters. */ atomisp_recover_params_queue (&isp->asd.video_out);
drivers/staging/media/atomisp/pci/atomisp_cmd.h +0 -1
@@ -59,7 +59,6 @@ int atomisp_buffers_in_css(struct atomisp_video_pipe *pipe);void atomisp_buffer_done (struct ia_css_frame *frame,enum vb2_buffer_state state);void atomisp_flush_video_pipe (struct atomisp_video_pipe *pipe,enum vb2_buffer_state state,bool warn_on_css_frames); -void atomisp_flush_bufs_and_wakeup (struct atomisp_sub_device *asd);void atomisp_clear_css_buffer_counters (struct atomisp_sub_device *asd);/* Interrupt functions */
Signature · 1 line
2.40.1
PATCH 11/30 media: atomisp: Remove atomisp_subdev_register_video_nodes() helper
In reply to Hans de GoedeNow that there is only 1 /dev/video# node left there is no need to do this in a helper. Just make atomisp_register_device_nodes() call ideo_register_device() directly.
--- .../staging/media/atomisp/pci/atomisp_subdev.c | 18 ------------------ .../staging/media/atomisp/pci/atomisp_subdev.h | 2 -- .../staging/media/atomisp/pci/atomisp_v4l2.c | 4 +++- 3 files changed, 3 insertions(+), 21 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_subdev.c +0 -18
@@ -1002,24 +1002,6 @@ int atomisp_subdev_register_subdev(struct atomisp_sub_device *asd,return v4l2_device_register_subdev (vdev, &asd->subdev); } -int atomisp_subdev_register_video_nodes (struct atomisp_sub_device *asd, -struct v4l2_device *vdev) -{ -int ret; - - asd->video_out.vdev.v4l2_dev = vdev; - asd->video_out.vdev.device_caps =V4L2_CAP_VIDEO_CAPTURE |V4L2_CAP_STREAMING ; - ret =video_register_device (&asd->video_out.vdev,VFL_TYPE_VIDEO ,-1 ); -if (ret <0 ) - goto error; - -return 0 ; - -error: -atomisp_subdev_unregister_entities (asd); -return ret; -} -/* * atomisp_subdev_init - ISP Subdevice initialization. * @dev: Device pointer specific to the ATOM ISP.
drivers/staging/media/atomisp/pci/atomisp_subdev.h +0 -2
@@ -367,8 +367,6 @@ void atomisp_subdev_cleanup_pending_events(struct atomisp_sub_device *asd);void atomisp_subdev_unregister_entities (struct atomisp_sub_device *asd);int atomisp_subdev_register_subdev (struct atomisp_sub_device *asd,struct v4l2_device *vdev); -int atomisp_subdev_register_video_nodes (struct atomisp_sub_device *asd, -struct v4l2_device *vdev);int atomisp_subdev_init (struct atomisp_device *isp);void atomisp_subdev_cleanup (struct atomisp_device *isp);int atomisp_create_pads_links (struct atomisp_device *isp);
drivers/staging/media/atomisp/pci/atomisp_v4l2.c +3 -1
@@ -1016,7 +1016,9 @@ static int atomisp_register_device_nodes(struct atomisp_device *isp) {int err; - err =atomisp_subdev_register_video_nodes (&isp->asd, &isp->v4l2_dev); + 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 );if (err)return err;
Signature · 1 line
2.40.1
Re: [PATCH 11/30] media: atomisp: Remove atomisp_subdev_register_video_nodes() helper
Quoted 4 lines · Hans de Goede
Now that there is only 1 /dev/video# node left there is no need to do this in a helper. Just make
atomisp_register_device_nodes()callideo_register_device()directly.
video_register_device()
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH 12/30 media: atomisp: Remove a bunch of unused atomisp_css_*() functions
In reply to Hans de GoedeRemove various unused atomisp_css_*() functions from atomisp_compat_css20.c.
--- .../media/atomisp/pci/atomisp_compat.h | 29 ------ .../media/atomisp/pci/atomisp_compat_css20.c | 99 ------------------- 2 files changed, 128 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_compat.h +0 -29
@@ -150,10 +150,6 @@ int atomisp_css_set_default_isys_config(struct atomisp_sub_device *asd,enum atomisp_input_stream_id stream_id, struct v4l2_mbus_framefmt *ffmt); -int atomisp_css_isys_two_stream_cfg (struct atomisp_sub_device *asd, -enum atomisp_input_stream_id stream_id, -enum atomisp_input_format input_format); - void atomisp_css_isys_two_stream_cfg_update_stream1( struct atomisp_sub_device *asd, enum atomisp_input_stream_id stream_id,
@@ -209,15 +205,6 @@ void atomisp_css_capture_enable_online(struct atomisp_sub_device *asd,void atomisp_css_preview_enable_online (struct atomisp_sub_device *asd,unsigned short stream_index,bool enable); -void atomisp_css_video_enable_online (struct atomisp_sub_device *asd, -bool enable); - -void atomisp_css_enable_continuous (struct atomisp_sub_device *asd, -bool enable); - -void atomisp_css_enable_cvf (struct atomisp_sub_device *asd, -bool enable); - int atomisp_css_input_configure_port(struct atomisp_sub_device *asd, enum mipi_port_id port, unsigned int num_lanes,
@@ -243,22 +230,6 @@ int atomisp_css_copy_configure_output(struct atomisp_sub_device *asd,unsigned int padded_width, enum ia_css_frame_format format); -int atomisp_css_yuvpp_configure_output (struct atomisp_sub_device *asd, -unsigned int stream_index, -unsigned int width,unsigned int height, -unsigned int padded_width, -enum ia_css_frame_format format); - -int atomisp_css_yuvpp_get_output_frame_info ( -struct atomisp_sub_device *asd, -unsigned int stream_index, -struct ia_css_frame_info *info); - -int atomisp_css_yuvpp_get_viewfinder_frame_info ( -struct atomisp_sub_device *asd, -unsigned int stream_index, -struct ia_css_frame_info *info); - int atomisp_css_preview_configure_output(struct atomisp_sub_device *asd, unsigned int width, unsigned int height, unsigned int min_width,
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +0 -99
117 lines not on this page · raw message
Signature · 1 line
2.40.1
PATCH 13/30 media: atomisp: Remove unused mipi_frame_size field from atomisp_[sub_]device
In reply to Hans de GoedeBoth the atomisp_device and the atomisp_sub_device structs have an used mipi_frame_size field, remove the field from both.
--- drivers/staging/media/atomisp/pci/atomisp_fops.c | 2 -- drivers/staging/media/atomisp/pci/atomisp_internal.h | 1 - drivers/staging/media/atomisp/pci/atomisp_subdev.h | 2 -- 3 files changed, 5 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_fops.c +0 -2
@@ -448,7 +448,6 @@ static void atomisp_dev_init_struct(struct atomisp_device *isp)unsigned int i; isp->isp_fatal_error = false; - isp->mipi_frame_size =0 ;for (i =0 ; i < isp->input_cnt; i++) isp->inputs[i].asd =NULL ;
@@ -478,7 +477,6 @@ static void atomisp_subdev_init_struct(struct atomisp_sub_device *asd)/* Add for channel */ asd->input_curr =0 ; - asd->mipi_frame_size =0 ; asd->copy_mode = false; asd->stream_prepared = false;
drivers/staging/media/atomisp/pci/atomisp_internal.h +0 -1
@@ -211,7 +211,6 @@ struct atomisp_device {spinlock_t lock;/* Protects asd.streaming */ -unsigned int mipi_frame_size;const struct atomisp_dfs_config *dfs;unsigned int hpll_freq;unsigned int running_freq;
drivers/staging/media/atomisp/pci/atomisp_subdev.h +0 -2
@@ -304,8 +304,6 @@ struct atomisp_sub_device {unsigned int latest_preview_exp_id;/* CSS ZSL/SDV raw buffer id */ -unsigned int mipi_frame_size; -bool copy_mode;/* CSI2+ use copy mode */ int raw_buffer_bitmap[ATOMISP_MAX_EXP_ID / 32 +
Signature · 1 line
2.40.1
Re: [PATCH 13/30] media: atomisp: Remove unused mipi_frame_size field from atomisp_[sub_]device
Quoted 3 lines · Hans de Goede
Both the
atomisp_deviceand theatomisp_sub_devicestructs have an usedmipi_frame_sizefield, remove the field from both.
I am confused. Perhaps 'an unused'?
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH 14/30 media: atomisp: Remove isp_timeout flag
In reply to Hans de Goedeisp_timeout only ever gets set in __atomisp_css_recover() and then immediately gets cleared again after calling atomisp_reset().
All this happens with isp->mutex held.
The only consumer of isp->isp_timeout is atomisp_stop_streaming(), which also holds isp->mutex and which is *not* called by atomisp_reset().
Since both hold isp->mutex and since __atomisp_css_recover() clears isp_timeout before releasing the mutex, atomisp_stop_streaming() can never see isp_timeout being true, so just remove the flag.
--- drivers/staging/media/atomisp/pci/atomisp_cmd.c | 8 +++----- drivers/staging/media/atomisp/pci/atomisp_internal.h | 2 -- drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 7 +------ 3 files changed, 4 insertions(+), 13 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_cmd.c +3 -5
@@ -935,7 +935,7 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, int error,atomisp_qbuffers_to_css (asd); } -static void __atomisp_css_recover (struct atomisp_device *isp,bool isp_timeout) +static void __atomisp_css_recover (struct atomisp_device *isp) {struct pci_dev *pdev =to_pci_dev (isp->dev);enum ia_css_pipe_id css_pipe_id;
@@ -992,9 +992,7 @@ static void __atomisp_css_recover(struct atomisp_device *isp, bool isp_timeout) isp->saved_regs.i_control | MRFLD_PCI_I_CONTROL_SRSE_RESET_MASK);/* reset ISP and restore its state */ - isp->isp_timeout = true;atomisp_reset (isp); - isp->isp_timeout = false;if (stream_restart) {atomisp_css_input_set_mode (&isp->asd,IA_CSS_INPUT_MODE_BUFFERED_SENSOR );
@@ -1043,14 +1041,14 @@ void atomisp_assert_recovery_work(struct work_struct *work) assert_recovery_work);mutex_lock (&isp->mutex); -__atomisp_css_recover (isp, true); +__atomisp_css_recover (isp);mutex_unlock (&isp->mutex); }void atomisp_css_flush (struct atomisp_device *isp) {/* Start recover */ -__atomisp_css_recover (isp, false); +__atomisp_css_recover (isp);dev_dbg (isp->dev,"atomisp css flush done\n" ); }
drivers/staging/media/atomisp/pci/atomisp_internal.h +0 -2
@@ -204,8 +204,6 @@ struct atomisp_device {struct atomisp_regs saved_regs;struct atomisp_css_env css_env; -/* isp timeout status flag */ -bool isp_timeout;bool isp_fatal_error;struct work_struct assert_recovery_work;
drivers/staging/media/atomisp/pci/atomisp_ioctl.c +1 -6
@@ -1369,11 +1369,7 @@ void atomisp_stop_streaming(struct vb2_queue *vq)/* * ISP work around, need to reset isp * Is it correct time to reset ISP when first node does streamoff? -*/ -if (isp->isp_timeout) -dev_err (isp->dev,"%s: Resetting with WA activated" , - __func__); -/* +* * It is possible that the other asd stream is in the stage * that v4l2_setfmt is just get called on it, which will * create css stream on that stream. But at this point, there
@@ -1403,7 +1399,6 @@ void atomisp_stop_streaming(struct vb2_queue *vq) } } - isp->isp_timeout = false; out_unlock:mutex_unlock (&isp->mutex); }
Signature · 1 line
2.40.1
PATCH 15/30 media: atomisp: Remove atomisp_sensor_start_stream()
In reply to Hans de GoedeNow that we no longer have continuous mode we always want to start the sensor on the first atomisp_start_streaming() call and stop it on the first atomisp_stop_streaming() call.
Remove atomisp_sensor_start_stream() which returned the number of streams which should be active before starting the sensor and always start/stop the sensor directly.
--- .../staging/media/atomisp/pci/atomisp_ioctl.c | 36 ------------------- 1 file changed, 36 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_ioctl.c +0 -36
@@ -1123,20 +1123,6 @@ enum ia_css_pipe_id atomisp_get_css_pipe_id(struct atomisp_sub_device *asd) } } -static unsigned int atomisp_sensor_start_stream (struct atomisp_sub_device *asd) -{ -if (asd->vfpp->val !=ATOMISP_VFPP_ENABLE || - asd->copy_mode) -return 1 ; - -if (asd->run_mode->val ==ATOMISP_RUN_MODE_VIDEO || - (asd->run_mode->val ==ATOMISP_RUN_MODE_STILL_CAPTURE && - !atomisp_is_mbuscode_raw (asd->fmt[ATOMISP_SUBDEV_PAD_SOURCE ].fmt.code))) -return 2 ; -else -return 1 ; -} -/* Input system HW workaround */ /* Input system address translation corrupts burst during */ /* invalidate. SW workaround for this is to set burst length */
@@ -1162,7 +1148,6 @@ int atomisp_start_streaming(struct vb2_queue *vq, unsigned int count)struct atomisp_device *isp = asd->isp;struct pci_dev *pdev =to_pci_dev (isp->dev);enum ia_css_pipe_id css_pipe_id; -unsigned int sensor_start_stream;unsigned long irqflags;int ret;
@@ -1177,18 +1162,6 @@ int atomisp_start_streaming(struct vb2_queue *vq, unsigned int count)/* Input system HW workaround */ atomisp_dma_burst_len_cfg (asd); -/* -* The number of streaming video nodes is based on which -* binary is going to be run. -*/ - sensor_start_stream =atomisp_sensor_start_stream (asd); - -if (atomisp_subdev_streaming_count (asd) > sensor_start_stream) { -atomisp_qbuffers_to_css (asd); - ret =0 ; - goto out_unlock; - } -if (asd->streaming ==ATOMISP_DEVICE_STREAMING_ENABLED ) {atomisp_qbuffers_to_css (asd); goto start_sensor;
@@ -1233,12 +1206,6 @@ int atomisp_start_streaming(struct vb2_queue *vq, unsigned int count)atomisp_qbuffers_to_css (asd); -/* Only start sensor when the last streaming instance started */ -if (atomisp_subdev_streaming_count (asd) < sensor_start_stream) { - ret =0 ; - goto out_unlock; - } - start_sensor:if (isp->flash) { asd->params.num_flash_frames =0 ;
@@ -1340,9 +1307,6 @@ void atomisp_stop_streaming(struct vb2_queue *vq)atomisp_subdev_cleanup_pending_events (asd); stopsensor: -if (atomisp_subdev_streaming_count (asd) !=atomisp_sensor_start_stream (asd)) - goto out_unlock; - ret =v4l2_subdev_call (isp->inputs[asd->input_curr].camera, video, s_stream,0 );
Signature · 1 line
2.40.1
PATCH 16/30 media: atomisp: Simplify atomisp_[start|stop]_streaming()
In reply to Hans de GoedeNow that continuous mode is gone and we only have 1 /dev/video# node, the videobuf2 core guarantees that atomisp_[start|stop]_streaming() will only be called one at a time.
So there is no need to check for things like the isp is already streaming when starting, or other streams still being active while stopping. Remove checks for these from atomisp_[start|stop]_streaming().
While at it also improve the logging a bit:
1. Remove the dev_err(isp->dev, "atomisp_reset") logged on every stream stop (even though everything is fine.
2. Log a message when starting/stopping the sensor stream fails
--- .../staging/media/atomisp/pci/atomisp_ioctl.c | 89 ++++--------------- 1 file changed, 17 insertions(+), 72 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_ioctl.c +17 -72
@@ -615,12 +615,6 @@ static int atomisp_enum_input(struct file *file, void *fh,return 0 ; } -static unsigned int -atomisp_subdev_streaming_count (struct atomisp_sub_device *asd) -{ -return vb2_start_streaming_called (&asd->video_out.vb_queue); -} -unsigned int atomisp_streaming_count (struct atomisp_device *isp) {return isp->asd.streaming ==ATOMISP_DEVICE_STREAMING_ENABLED ;
@@ -1162,11 +1156,6 @@ int atomisp_start_streaming(struct vb2_queue *vq, unsigned int count)/* Input system HW workaround */ atomisp_dma_burst_len_cfg (asd); -if (asd->streaming ==ATOMISP_DEVICE_STREAMING_ENABLED ) { -atomisp_qbuffers_to_css (asd); - goto start_sensor; - } - css_pipe_id =atomisp_get_css_pipe_id (asd);/* Invalidate caches. FIXME: should flush only necessary buffers */
@@ -1206,7 +1195,6 @@ int atomisp_start_streaming(struct vb2_queue *vq, unsigned int count)atomisp_qbuffers_to_css (asd); -start_sensor:if (isp->flash) { asd->params.num_flash_frames =0 ; asd->params.flash_state =ATOMISP_FLASH_IDLE ;
@@ -1216,19 +1204,9 @@ int atomisp_start_streaming(struct vb2_queue *vq, unsigned int count)atomisp_css_irq_enable (isp,IA_CSS_IRQ_INFO_CSS_RECEIVER_SOF ,atomisp_css_valid_sof (isp));atomisp_csi2_configure (asd); -/* -* set freq to max when streaming count > 1 which indicate -* dual camera would run -*/ -if (atomisp_streaming_count (isp) >1 ) { -if (atomisp_freq_scaling (isp, -ATOMISP_DFS_MODE_MAX , false) <0 ) -dev_dbg (isp->dev,"DFS max mode failed!\n" ); - }else { -if (atomisp_freq_scaling (isp, -ATOMISP_DFS_MODE_AUTO , false) <0 ) -dev_dbg (isp->dev,"DFS auto mode failed!\n" ); - } + +if (atomisp_freq_scaling (isp,ATOMISP_DFS_MODE_AUTO , false) <0 ) +dev_dbg (isp->dev,"DFS auto mode failed!\n" );/* Enable the CSI interface on ANN B0/K0 */ if (isp->media_dev.hw_revision >= ((ATOMISP_HW_REVISION_ISP2401 <<
@@ -1241,6 +1219,7 @@ int atomisp_start_streaming(struct vb2_queue *vq, unsigned int count) ret =v4l2_subdev_call (isp->inputs[asd->input_curr].camera, video, s_stream,1 );if (ret) { +dev_err (isp->dev,"Starting sensor stream failed: %d\n" , ret);spin_lock_irqsave (&isp->lock, irqflags); asd->streaming =ATOMISP_DEVICE_STREAMING_DISABLED ;spin_unlock_irqrestore (&isp->lock, irqflags);
@@ -1260,8 +1239,6 @@ void atomisp_stop_streaming(struct vb2_queue *vq)struct atomisp_device *isp = asd->isp;struct pci_dev *pdev =to_pci_dev (isp->dev);enum ia_css_pipe_id css_pipe_id; -bool recreate_stream = false; -bool first_streamoff = false;unsigned long flags;int ret;
@@ -1284,19 +1261,10 @@ void atomisp_stop_streaming(struct vb2_queue *vq)if (ret ==0 )dev_warn (isp->dev,"Warning timeout waiting for CSS to return buffers\n" ); -if (asd->streaming ==ATOMISP_DEVICE_STREAMING_ENABLED ) - first_streamoff = true; -spin_lock_irqsave (&isp->lock, flags); -if (atomisp_subdev_streaming_count (asd) ==1 ) - asd->streaming =ATOMISP_DEVICE_STREAMING_DISABLED ; -else - asd->streaming =ATOMISP_DEVICE_STREAMING_STOPPING ; + asd->streaming =ATOMISP_DEVICE_STREAMING_DISABLED ;spin_unlock_irqrestore (&isp->lock, flags); -if (!first_streamoff) - goto stopsensor; -atomisp_clear_css_buffer_counters (asd);atomisp_css_irq_enable (isp,IA_CSS_IRQ_INFO_CSS_RECEIVER_SOF , false);
@@ -1306,21 +1274,17 @@ void atomisp_stop_streaming(struct vb2_queue *vq)atomisp_flush_video_pipe (pipe,VB2_BUF_STATE_ERROR , true);atomisp_subdev_cleanup_pending_events (asd); -stopsensor: + ret =v4l2_subdev_call (isp->inputs[asd->input_curr].camera, video, s_stream,0 ); +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 ; } -/* if other streams are running, isp should not be powered off */ -if (atomisp_streaming_count (isp)) { -atomisp_css_flush (isp); - goto out_unlock; - } -/* 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 )) {
@@ -1330,40 +1294,21 @@ void atomisp_stop_streaming(struct vb2_queue *vq)if (atomisp_freq_scaling (isp,ATOMISP_DFS_MODE_LOW , false))dev_warn (isp->dev,"DFS failed.\n" ); -/* -* ISP work around, need to reset isp -* Is it correct time to reset ISP when first node does streamoff? -* -* It is possible that the other asd stream is in the stage -* that v4l2_setfmt is just get called on it, which will -* create css stream on that stream. But at this point, there -* is no way to destroy the css stream created on that stream. -* -* So force stream destroy here. -*/ -if (isp->asd.stream_prepared) { -atomisp_destroy_pipes_stream_force (&isp->asd); - recreate_stream = true; - } -/* disable PUNIT/ISP acknowlede/handshake - SRSE=3 */ +/* +* ISP work around, need to reset ISP to allow next stream on to work. +* Streams have already been destroyed by atomisp_css_stop(). +* Disable PUNIT/ISP acknowlede/handshake - SRSE=3 and then reset. +*/ pci_write_config_dword (pdev,PCI_I_CONTROL , isp->saved_regs.i_control |MRFLD_PCI_I_CONTROL_SRSE_RESET_MASK ); -dev_err (isp->dev,"atomisp_reset" );atomisp_reset (isp); -if (recreate_stream) { -int ret2; +/* Streams were destroyed by atomisp_css_stop(), recreate them. */ + ret =atomisp_create_pipes_stream (&isp->asd); +if (ret) +dev_warn (isp->dev,"Recreating streams failed: %d\n" , ret); - ret2 =atomisp_create_pipes_stream (&isp->asd); -if (ret2) { -dev_err (isp->dev,"%s error re-creating streams: %d\n" , __func__, ret2); -if (!ret) - ret = ret2; - } - } - -out_unlock:mutex_unlock (&isp->mutex); }
Signature · 1 line
2.40.1
PATCH 17/30 media: atomisp: Simplify atomisp_css_[start|stop]()
In reply to Hans de GoedeNow that continuous mode is gone and we only have 1 /dev/video# node, the videobuf2 core guarantees that atomisp_css_[start|stop]() will only be called one at a time.
So there is no need for atomisp_streaming_count() counts.
When reqbufs has been done then the streams are guaranteed to be created, and streaming cannot be started without reqbufs so there is no need for atomisp_css_start() to check if it needs to create the streams.
Use this to clean-up atomisp_css_[start|stop]().
While at it also fix atomisp_css_start() not re-creating the streams on an error, breaking the guarantee that the streams are always there after a succesfull reqbufs call.
--- .../media/atomisp/pci/atomisp_compat_css20.c | 68 ++++++------------- 1 file changed, 20 insertions(+), 48 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +20 -48
@@ -1001,42 +1001,17 @@ int atomisp_css_start(struct atomisp_sub_device *asd,wbinvd (); } -/* -* For dual steam case, it is possible that: -* 1: for this stream, it is at the stage that: -* - after set_fmt is called -* - before stream on is called -* 2: for the other stream, the stream off is called which css reset -* has been done. -* -* Thus the stream created in set_fmt get destroyed and need to be -* recreated in the next stream on. -*/ -if (!asd->stream_prepared) { - ret =atomisp_create_pipes_stream (asd); -if (ret) -return ret; - } -/* -* SP can only be started one time -* if atomisp_subdev_streaming_count() tell there already has some -* subdev at streamming, then SP should already be started previously, -* so need to skip start sp procedure -*/ -if (atomisp_streaming_count (isp)) { -dev_dbg (isp->dev,"skip start sp\n" ); - }else { -if (!sh_css_hrt_system_is_idle ()) -dev_err (isp->dev,"CSS HW not idle before starting SP\n" ); -if (ia_css_start_sp ()) { -dev_err (isp->dev,"start sp error.\n" ); - ret = -EINVAL ; - goto start_err; - }else { - sp_is_started = true; - } +if (!sh_css_hrt_system_is_idle ()) +dev_err (isp->dev,"CSS HW not idle before starting SP\n" ); + +if (ia_css_start_sp ()) { +dev_err (isp->dev,"start sp error.\n" ); + ret = -EINVAL ; + goto start_err; } + sp_is_started = true; +for (i =0 ; i <ATOMISP_INPUT_STREAM_NUM ; i++) {if (asd->stream_env[i].stream) { if (ia_css_stream_start(asd->stream_env[i]
@@ -1054,16 +1029,15 @@ int atomisp_css_start(struct atomisp_sub_device *asd,return 0 ; start_err: -atomisp_destroy_pipes_stream_force (asd); - -/* css 2.0 API limitation: ia_css_stop_sp() could be only called after -* destroy all pipes -*/ /* -* SP can not be stop if other streams are in use +* CSS 2.0 API limitation: ia_css_stop_sp() can only be called after +* destroying all pipes. */ -if ((atomisp_streaming_count (isp) ==0 ) && sp_is_started) +if (sp_is_started) { +atomisp_destroy_pipes_stream_force (asd);ia_css_stop_sp (); +atomisp_create_pipes_stream (asd); + }return ret; }
@@ -1843,20 +1817,18 @@ int atomisp_css_input_configure_port(void atomisp_css_stop (struct atomisp_sub_device *asd,enum ia_css_pipe_id pipe_id,bool in_reset) { -struct atomisp_device *isp = asd->isp;unsigned long irqflags;unsigned int i; -/* if is called in atomisp_reset(), force destroy streams and pipes */ +/* +* CSS 2.0 API limitation: ia_css_stop_sp() can only be called after +* destroying all pipes. +*/ atomisp_destroy_pipes_stream_force (asd);atomisp_init_raw_buffer_bitmap (asd); -/* -* SP can not be stop if other streams are in use -*/ -if (atomisp_streaming_count (isp) ==0 ) -ia_css_stop_sp (); +ia_css_stop_sp ();if (!in_reset) {struct atomisp_stream_env *stream_env;
Signature · 1 line
2.40.1
PATCH 18/30 media: atomisp: Simplify atomisp_open() and atomisp_release()
In reply to Hans de GoedeNow that continuous mode is gone and we only have 1 /dev/video# node, combined with only allowing 1 open of that /dev/video# node for now, there is no need to check for other (sub)dev / pipe users.
Remove the unnecessary checks for a nice cleanup.
Note we also don't need to set asd->streaming to disabled since the vb2_fop_release() call done by atomisp_release() will have called atomisp_stop_streaming() already at this point (if necessary) and that will have already done this.
--- .../staging/media/atomisp/pci/atomisp_fops.c | 26 ------------------- 1 file changed, 26 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_fops.c +0 -26
@@ -532,11 +532,6 @@ static int atomisp_open(struct file *file)return -EBUSY ; } -if (atomisp_dev_users (isp)) { -dev_dbg (isp->dev,"skip init isp in open\n" ); - goto init_subdev; - } -/* runtime power management, turn on ISP */ ret =pm_runtime_resume_and_get (vdev->v4l2_dev->dev);if (ret <0 ) {
@@ -552,19 +547,12 @@ static int atomisp_open(struct file *file) goto css_error; } -init_subdev: -if (atomisp_subdev_users (asd)) - goto done; -atomisp_subdev_init_struct (asd);/* Ensure that a mode is set */ v4l2_ctrl_s_ctrl (asd->run_mode, pipe->default_run_mode); -done: pipe->users++;mutex_unlock (&isp->mutex); - -return 0 ; css_error:
@@ -583,7 +571,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 }; -unsigned long flags;int ret;v4l2_fh_init (&fh.vfh, vdev);
@@ -598,8 +585,6 @@ static int atomisp_release(struct file *file)mutex_lock (&isp->mutex); pipe->users--; -if (pipe->users) - goto done;/* * A little trick here:
@@ -616,9 +601,6 @@ static int atomisp_release(struct file *file) ATOMISP_SUBDEV_PAD_SINK, &isp_sink_fmt); } -if (atomisp_subdev_users (asd)) - goto done; -atomisp_css_free_stat_buffers (asd);atomisp_free_internal_buffers (asd);
@@ -632,13 +614,6 @@ static int atomisp_release(struct file *file) isp->inputs[asd->input_curr].asd =NULL ; } -spin_lock_irqsave (&isp->lock, flags); - asd->streaming =ATOMISP_DEVICE_STREAMING_DISABLED ; -spin_unlock_irqrestore (&isp->lock, flags); - -if (atomisp_dev_users (isp)) - goto done; -atomisp_destroy_pipes_stream_force (asd); ret =v4l2_subdev_call (isp->flash, core, s_power,0 );
@@ -648,7 +623,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" ); -done: atomisp_subdev_set_selection(&asd->subdev, fh.state, V4L2_SUBDEV_FORMAT_ACTIVE, ATOMISP_SUBDEV_PAD_SOURCE,
Signature · 1 line
2.40.1
PATCH 19/30 media: atomisp: Simplify atomisp_pipe_check()
In reply to Hans de GoedeAll switch (pipe->asd->streaming) cases in atomisp_pipe_check() are either no-ops or never happen:
1. ATOMISP_DEVICE_STREAMING_DISABLED already is a no-op
2. The videobuf2 core guarantees that when we are streaming vb2_is_busy() returns true. So the ATOMISP_DEVICE_STREAMING_ENABLED case is already handled by the if above the switch (pipe->asd->streaming).
3. After recent changes pipe->asd->streaming is only ever set to ATOMISP_DEVICE_STREAMING_STOPPING in atomisp_assert_recovery_work() and that function holds isp->mutex and always transitions the streaming state to ATOMISP_DEVICE_STREAMING_DISABLED or ATOMISP_DEVICE_STREAMING_ENABLED before releasing the mutex. So atomisp_pipe_check() never sees ATOMISP_DEVICE_STREAMING_STOPPING.
Remove the entire switch-case.
--- .../staging/media/atomisp/pci/atomisp_ioctl.c | 16 ---------------- 1 file changed, 16 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_ioctl.c +0 -16
@@ -528,22 +528,6 @@ int atomisp_pipe_check(struct atomisp_video_pipe *pipe, bool settings_change)return -EBUSY ; } -switch (pipe->asd->streaming) { -case ATOMISP_DEVICE_STREAMING_DISABLED : -break ; -case ATOMISP_DEVICE_STREAMING_ENABLED : -if (settings_change) { -dev_err (pipe->isp->dev,"Set fmt/input IOCTL while streaming\n" ); -return -EBUSY ; - } -break ; -case ATOMISP_DEVICE_STREAMING_STOPPING : -dev_err (pipe->isp->dev,"IOCTL issued while stopping\n" ); -return -EBUSY ; -default : -return -EINVAL ; - } -return 0 ; }
Signature · 1 line
2.40.1
PATCH 20/30 media: atomisp: Turn asd->streaming state tracker into a bool
In reply to Hans de GoedeThe ATOMISP_DEVICE_STREAMING_STOPPING pipe state comes from when we still had continuous mode. This would be set when streaming from both capture + preview devnodes when 1 of the 2 streams has been stopped and the driver was waiting for the other stream to get stopped too.
With continuous mode gone the stopping state is no longer necessary and asd->streaming can be changed to a bool.
Note that atomisp_assert_recovery_work() would still temporarily set streaming to stopping, but it does so with the isp->mutex held and changes streaming to either enabled or disabled before releasing the mutex, so none of the consumers which care about the difference ever see the stopping state.
--- .../staging/media/atomisp/pci/atomisp_cmd.c | 21 +++++++------------ .../media/atomisp/pci/atomisp_compat_css20.c | 4 ++-- .../staging/media/atomisp/pci/atomisp_fops.c | 2 +- .../media/atomisp/pci/atomisp_internal.h | 4 ---- .../staging/media/atomisp/pci/atomisp_ioctl.c | 8 +++---- .../media/atomisp/pci/atomisp_subdev.h | 2 +- .../staging/media/atomisp/pci/atomisp_v4l2.c | 2 +- 7 files changed, 17 insertions(+), 26 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_cmd.c +8 -13
@@ -475,7 +475,7 @@ irqreturn_t atomisp_isr(int irq, void *dev)if (!atomisp_streaming_count (isp)) goto out_nowake; -if (isp->asd.streaming ==ATOMISP_DEVICE_STREAMING_ENABLED ) { +if (isp->asd.streaming) {if (irq_infos &IA_CSS_IRQ_INFO_CSS_RECEIVER_SOF ) {atomic_inc (&isp->asd.sof_count);atomisp_sof_event (&isp->asd);
@@ -950,12 +950,11 @@ static void __atomisp_css_recover(struct atomisp_device *isp)atomisp_css_irq_enable (isp,IA_CSS_IRQ_INFO_CSS_RECEIVER_SOF , false); -if (isp->asd.streaming ==ATOMISP_DEVICE_STREAMING_ENABLED || - isp->asd.stream_prepared) { +if (isp->asd.streaming || isp->asd.stream_prepared) { stream_restart = true;spin_lock_irqsave (&isp->lock, flags); - isp->asd.streaming =ATOMISP_DEVICE_STREAMING_STOPPING ; + isp->asd.streaming = false;spin_unlock_irqrestore (&isp->lock, flags);/* stream off sensor */
@@ -971,10 +970,6 @@ static void __atomisp_css_recover(struct atomisp_device *isp) css_pipe_id =atomisp_get_css_pipe_id (&isp->asd);atomisp_css_stop (&isp->asd, css_pipe_id, true); -spin_lock_irqsave (&isp->lock, flags); - isp->asd.streaming =ATOMISP_DEVICE_STREAMING_DISABLED ; -spin_unlock_irqrestore (&isp->lock, flags); - isp->asd.preview_exp_id =1 ; isp->asd.postview_exp_id =1 ;/* notify HAL the CSS reset */
@@ -1003,7 +998,7 @@ static void __atomisp_css_recover(struct atomisp_device *isp) "start SP failed, so do not set streaming to be enable!\n"); }else {spin_lock_irqsave (&isp->lock, flags); - isp->asd.streaming =ATOMISP_DEVICE_STREAMING_ENABLED ; + isp->asd.streaming = true;spin_unlock_irqrestore (&isp->lock, flags); }
@@ -1128,7 +1123,7 @@ irqreturn_t atomisp_isr_thread(int irq, void *isp_ptr)if (atomisp_css_isr_thread (isp)) goto out; -if (isp->asd.streaming ==ATOMISP_DEVICE_STREAMING_ENABLED ) +if (isp->asd.streaming)atomisp_setup_flash (&isp->asd); out:mutex_unlock (&isp->mutex);
@@ -3211,7 +3206,7 @@ void atomisp_handle_parameter_and_buffer(struct atomisp_video_pipe *pipe)* CSS/FW requires set parameter and enqueue buffer happen after ISP * is streamon. */ -if (asd->streaming !=ATOMISP_DEVICE_STREAMING_ENABLED ) +if (!asd->streaming)return ; if (list_empty(&pipe->per_frame_params) ||
@@ -4761,7 +4756,7 @@ static int __checking_exp_id(struct atomisp_sub_device *asd, int exp_id)dev_warn (isp->dev,"%s Raw Buffer Lock is disable.\n" , __func__);return -EINVAL ; } -if (asd->streaming !=ATOMISP_DEVICE_STREAMING_ENABLED ) { +if (!asd->streaming) {dev_err (isp->dev,"%s streaming %d invalid exp_id %d.\n" , __func__, exp_id, asd->streaming);return -EINVAL ;
@@ -4883,7 +4878,7 @@ int atomisp_enable_dz_capt_pipe(struct atomisp_sub_device *asd,int atomisp_inject_a_fake_event (struct atomisp_sub_device *asd,int *event) { -if (!event || asd->streaming !=ATOMISP_DEVICE_STREAMING_ENABLED ) +if (!event || !asd->streaming)return -EINVAL ;lockdep_assert_held (&asd->isp->mutex);
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +2 -2
@@ -3081,7 +3081,7 @@ int atomisp_css_get_dis_stat(struct atomisp_sub_device *asd,return -EINVAL ;/* isp needs to be streaming to get DIS statistics */ -if (asd->streaming !=ATOMISP_DEVICE_STREAMING_ENABLED ) +if (!asd->streaming)return -EINVAL ;if (atomisp_compare_dvs_grid (asd, &stats->dvs2_stat.grid_info) !=0 )
@@ -3210,7 +3210,7 @@ static bool atomisp_css_isr_get_stream_id(struct ia_css_pipe *css_pipe,struct atomisp_stream_env *stream_env;int i, j; -if (isp->asd.streaming ==ATOMISP_DEVICE_STREAMING_DISABLED ) +if (!isp->asd.streaming)return false;for (i =0 ; i <ATOMISP_INPUT_STREAM_NUM ; i++) {
drivers/staging/media/atomisp/pci/atomisp_fops.c +1 -1
@@ -411,7 +411,7 @@ static void atomisp_buf_queue(struct vb2_buffer *vb)spin_unlock_irqrestore (&pipe->irq_lock, irqflags);/* TODO: do this better, not best way to queue to css */ -if (asd->streaming ==ATOMISP_DEVICE_STREAMING_ENABLED ) { +if (asd->streaming) {if (!list_empty (&pipe->buffers_waiting_for_param))atomisp_handle_parameter_and_buffer (pipe);else
drivers/staging/media/atomisp/pci/atomisp_internal.h +0 -4
@@ -168,10 +168,6 @@ struct atomisp_regs {u32 csi_access_viol; }; -#define ATOMISP_DEVICE_STREAMING_DISABLED 0 -#define ATOMISP_DEVICE_STREAMING_ENABLED 1 -#define ATOMISP_DEVICE_STREAMING_STOPPING 2 -/* * ci device struct */
drivers/staging/media/atomisp/pci/atomisp_ioctl.c +4 -4
@@ -601,7 +601,7 @@ static int atomisp_enum_input(struct file *file, void *fh,unsigned int atomisp_streaming_count (struct atomisp_device *isp) { -return isp->asd.streaming ==ATOMISP_DEVICE_STREAMING_ENABLED ; +return isp->asd.streaming; }/*
@@ -1163,7 +1163,7 @@ int atomisp_start_streaming(struct vb2_queue *vq, unsigned int count) }spin_lock_irqsave (&isp->lock, irqflags); - asd->streaming =ATOMISP_DEVICE_STREAMING_ENABLED ; + asd->streaming = true;spin_unlock_irqrestore (&isp->lock, irqflags);atomic_set (&asd->sof_count,-1 );atomic_set (&asd->sequence,-1 );
@@ -1205,7 +1205,7 @@ int atomisp_start_streaming(struct vb2_queue *vq, unsigned int count)if (ret) {dev_err (isp->dev,"Starting sensor stream failed: %d\n" , ret);spin_lock_irqsave (&isp->lock, irqflags); - asd->streaming =ATOMISP_DEVICE_STREAMING_DISABLED ; + asd->streaming = false;spin_unlock_irqrestore (&isp->lock, irqflags); ret = -EINVAL ; goto out_unlock;
@@ -1246,7 +1246,7 @@ void atomisp_stop_streaming(struct vb2_queue *vq)dev_warn (isp->dev,"Warning timeout waiting for CSS to return buffers\n" );spin_lock_irqsave (&isp->lock, flags); - asd->streaming =ATOMISP_DEVICE_STREAMING_DISABLED ; + asd->streaming = false;spin_unlock_irqrestore (&isp->lock, flags);atomisp_clear_css_buffer_counters (asd);
drivers/staging/media/atomisp/pci/atomisp_subdev.h +1 -1
@@ -299,7 +299,7 @@ struct atomisp_sub_device {* Writers of streaming must hold both isp->mutex and isp->lock. * Readers of streaming need to hold only one of the two locks. */ -unsigned int streaming; +bool streaming;bool stream_prepared;/* whether css stream is created */ unsigned int latest_preview_exp_id;/* CSS ZSL/SDV raw buffer id */
drivers/staging/media/atomisp/pci/atomisp_v4l2.c +1 -1
@@ -672,7 +672,7 @@ static int atomisp_suspend(struct device *dev)return -EBUSY ;spin_lock_irqsave (&isp->lock, flags); -if (isp->asd.streaming !=ATOMISP_DEVICE_STREAMING_DISABLED ) { +if (isp->asd.streaming) {spin_unlock_irqrestore (&isp->lock, flags);dev_err (isp->dev,"atomisp cannot suspend at this time.\n" );return -EINVAL ;
Signature · 1 line
2.40.1
PATCH 21/30 media: atomisp: Remove no longer used atomisp_css_flush()
In reply to Hans de GoedeRemove the no longer used atomisp_css_flush() function and merge atomisp_assert_recovery_work() and __atomisp_css_recover() into a single function.
--- .../staging/media/atomisp/pci/atomisp_cmd.c | 25 +++++-------------- .../staging/media/atomisp/pci/atomisp_cmd.h | 2 -- 2 files changed, 6 insertions(+), 21 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_cmd.c +6 -19
@@ -935,18 +935,20 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, int error,atomisp_qbuffers_to_css (asd); } -static void __atomisp_css_recover (struct atomisp_device *isp) +void atomisp_assert_recovery_work (struct work_struct *work) { + struct atomisp_device *isp = container_of(work, struct atomisp_device, + assert_recovery_work);struct pci_dev *pdev =to_pci_dev (isp->dev);enum ia_css_pipe_id css_pipe_id;bool stream_restart = false;unsigned long flags;int ret; -lockdep_assert_held (&isp->mutex); +mutex_lock (&isp->mutex);if (!atomisp_streaming_count (isp)) -return ; + goto out_unlock;atomisp_css_irq_enable (isp,IA_CSS_IRQ_INFO_CSS_RECEIVER_SOF , false);
@@ -1028,26 +1030,11 @@ static void __atomisp_css_recover(struct atomisp_device *isp)dev_warn (isp->dev,"can't start streaming on sensor!\n" ); } -} -void atomisp_assert_recovery_work (struct work_struct *work) -{ - struct atomisp_device *isp = container_of(work, struct atomisp_device, - assert_recovery_work); - -mutex_lock (&isp->mutex); -__atomisp_css_recover (isp); +out_unlock:mutex_unlock (&isp->mutex); } -void atomisp_css_flush (struct atomisp_device *isp) -{ -/* Start recover */ -__atomisp_css_recover (isp); - -dev_dbg (isp->dev,"atomisp css flush done\n" ); -} -void atomisp_setup_flash (struct atomisp_sub_device *asd) {struct atomisp_device *isp = asd->isp;
drivers/staging/media/atomisp/pci/atomisp_cmd.h +0 -2
@@ -282,8 +282,6 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, int error,enum ia_css_pipe_id css_pipe_id, bool q_buffers, enum atomisp_input_stream_id stream_id); -void atomisp_css_flush (struct atomisp_device *isp); -/* Events. Only one event has to be exported for now. */ void atomisp_eof_event (struct atomisp_sub_device *asd,uint8_t exp_id);
Signature · 1 line
2.40.1
PATCH 22/30 media: atomisp: Remove atomisp_streaming_count()
In reply to Hans de Goedeatomisp_streaming_count() is just an alias for isp->asd.streaming now, replace it with directly checking that and remove the helper.
--- drivers/staging/media/atomisp/pci/atomisp_cmd.c | 6 +++--- drivers/staging/media/atomisp/pci/atomisp_drvfs.c | 2 +- drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 5 ----- drivers/staging/media/atomisp/pci/atomisp_ioctl.h | 2 -- 4 files changed, 4 insertions(+), 11 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_cmd.c +3 -3
@@ -472,7 +472,7 @@ irqreturn_t atomisp_isr(int irq, void *dev)clear_irq_reg (isp); -if (!atomisp_streaming_count (isp)) +if (!isp->asd.streaming) goto out_nowake;if (isp->asd.streaming) {
@@ -947,7 +947,7 @@ void atomisp_assert_recovery_work(struct work_struct *work)mutex_lock (&isp->mutex); -if (!atomisp_streaming_count (isp)) +if (!isp->asd.streaming) goto out_unlock;atomisp_css_irq_enable (isp,IA_CSS_IRQ_INFO_CSS_RECEIVER_SOF , false);
@@ -1074,7 +1074,7 @@ irqreturn_t atomisp_isr_thread(int irq, void *isp_ptr)spin_lock_irqsave (&isp->lock, flags); -if (!atomisp_streaming_count (isp)) { +if (!isp->asd.streaming) {spin_unlock_irqrestore (&isp->lock, flags);return IRQ_HANDLED ; }
drivers/staging/media/atomisp/pci/atomisp_drvfs.c +1 -1
@@ -69,7 +69,7 @@ static inline int iunit_dump_dbgopt(struct atomisp_device *isp, }if (opt &OPTION_BIN_RUN ) { -if (atomisp_streaming_count (isp)) { +if (isp->asd.streaming) {atomisp_css_dump_sp_raw_copy_linecount (true);atomisp_css_debug_dump_isp_binary (); }else {
drivers/staging/media/atomisp/pci/atomisp_ioctl.c +0 -5
@@ -599,11 +599,6 @@ static int atomisp_enum_input(struct file *file, void *fh,return 0 ; } -unsigned int atomisp_streaming_count (struct atomisp_device *isp) -{ -return isp->asd.streaming; -} -/* * get input are used to get current primary/secondary camera */
drivers/staging/media/atomisp/pci/atomisp_ioctl.h +0 -2
@@ -47,8 +47,6 @@ enum ia_css_pipe_id atomisp_get_css_pipe_id(struct atomisp_sub_deviceextern const struct v4l2_ioctl_ops atomisp_ioctl_ops; -unsigned int atomisp_streaming_count (struct atomisp_device *isp); -/* compat_ioctl for 32bit userland app and 64bit kernel */ long atomisp_compat_ioctl32 (struct file *file,unsigned int cmd,unsigned long arg);
Signature · 1 line
2.40.1
PATCH 23/30 media: atomisp: Simplify atomisp_isr() and recovery_work()
In reply to Hans de GoedeBoth atomisp_isr() and recovery_work() now have a combination of:
1. "if (!isp->asd.streaming) goto out;" code at the top
2. "if (sp->asd.streaming) {}" blocks in the body which are jumped over by the goto out.
This means that the "if (sp->asd.streaming) {}" blocks are always executed if they are not jumped over by the goto.
Remove the unnecessary "if (sp->asd.streaming)" checks and re-indent the code.
--- .../staging/media/atomisp/pci/atomisp_cmd.c | 128 +++++++----------- 1 file changed, 50 insertions(+), 78 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_cmd.c +50 -78
@@ -475,36 +475,28 @@ irqreturn_t atomisp_isr(int irq, void *dev)if (!isp->asd.streaming) goto out_nowake; -if (isp->asd.streaming) { -if (irq_infos &IA_CSS_IRQ_INFO_CSS_RECEIVER_SOF ) { -atomic_inc (&isp->asd.sof_count); -atomisp_sof_event (&isp->asd); - -/* If sequence_temp and sequence are the same -* there where no frames lost so we can increase -* sequence_temp. -* If not then processing of frame is still in progress -* and driver needs to keep old sequence_temp value. -* NOTE: There is assumption here that ISP will not -* start processing next frame from sensor before old -* one is completely done. */ -if (atomic_read (&isp->asd.sequence) == -atomic_read (&isp->asd.sequence_temp)) -atomic_set (&isp->asd.sequence_temp, -atomic_read (&isp->asd.sof_count)); - } -if (irq_infos &IA_CSS_IRQ_INFO_EVENTS_READY ) -atomic_set (&isp->asd.sequence, -atomic_read (&isp->asd.sequence_temp)); - } -if (irq_infos &IA_CSS_IRQ_INFO_CSS_RECEIVER_SOF ) { -dev_dbg_ratelimited (isp->dev, -"irq:0x%x (SOF)\n" , - irq_infos); +atomic_inc (&isp->asd.sof_count); +atomisp_sof_event (&isp->asd); + +/* +* If sequence_temp and sequence are the same there where no frames +* lost so we can increase sequence_temp. +* If not then processing of frame is still in progress and driver +* needs to keep old sequence_temp value. +* NOTE: There is assumption here that ISP will not start processing +* next frame from sensor before old one is completely done. +*/ +if (atomic_read (&isp->asd.sequence) ==atomic_read (&isp->asd.sequence_temp)) +atomic_set (&isp->asd.sequence_temp,atomic_read (&isp->asd.sof_count)); + +dev_dbg_ratelimited (isp->dev,"irq:0x%x (SOF)\n" , irq_infos); irq_infos &= ~IA_CSS_IRQ_INFO_CSS_RECEIVER_SOF ; } +if (irq_infos &IA_CSS_IRQ_INFO_EVENTS_READY ) +atomic_set (&isp->asd.sequence,atomic_read (&isp->asd.sequence_temp)); +if ((irq_infos &IA_CSS_IRQ_INFO_INPUT_SYSTEM_ERROR ) || (irq_infos &IA_CSS_IRQ_INFO_IF_ERROR )) {/* handle mipi receiver error */
@@ -941,7 +933,6 @@ void atomisp_assert_recovery_work(struct work_struct *work) assert_recovery_work);struct pci_dev *pdev =to_pci_dev (isp->dev);enum ia_css_pipe_id css_pipe_id; -bool stream_restart = false;unsigned long flags;int ret;
@@ -952,33 +943,25 @@ void atomisp_assert_recovery_work(struct work_struct *work)atomisp_css_irq_enable (isp,IA_CSS_IRQ_INFO_CSS_RECEIVER_SOF , false); -if (isp->asd.streaming || isp->asd.stream_prepared) { - stream_restart = true; +spin_lock_irqsave (&isp->lock, flags); + isp->asd.streaming = false; +spin_unlock_irqrestore (&isp->lock, flags); -spin_lock_irqsave (&isp->lock, flags); - isp->asd.streaming = false; -spin_unlock_irqrestore (&isp->lock, flags); +/* stream off sensor */ + ret =v4l2_subdev_call (isp->inputs[isp->asd.input_curr].camera, video, s_stream,0 ); +if (ret) +dev_warn (isp->dev,"Stopping sensor stream failed: %d\n" , ret); -/* stream off sensor */ - ret =v4l2_subdev_call ( - isp->inputs[isp->asd.input_curr]. - camera, video, s_stream,0 ); -if (ret) -dev_warn (isp->dev, -"can't stop streaming on sensor!\n" ); +atomisp_clear_css_buffer_counters (&isp->asd); -atomisp_clear_css_buffer_counters (&isp->asd); + css_pipe_id =atomisp_get_css_pipe_id (&isp->asd); +atomisp_css_stop (&isp->asd, css_pipe_id, true); - css_pipe_id =atomisp_get_css_pipe_id (&isp->asd); -atomisp_css_stop (&isp->asd, css_pipe_id, true); - - isp->asd.preview_exp_id =1 ; - isp->asd.postview_exp_id =1 ; -/* notify HAL the CSS reset */ -dev_dbg (isp->dev, -"send reset event to %s\n" , isp->asd.subdev.devnode->name); -atomisp_reset_event (&isp->asd); - } + isp->asd.preview_exp_id =1 ; + isp->asd.postview_exp_id =1 ; +/* notify HAL the CSS reset */ +dev_dbg (isp->dev,"send reset event to %s\n" , isp->asd.subdev.devnode->name); +atomisp_reset_event (&isp->asd);/* clear irq */ disable_isp_irq (hrt_isp_css_irq_sp);
@@ -991,45 +974,34 @@ void atomisp_assert_recovery_work(struct work_struct *work)/* reset ISP and restore its state */ atomisp_reset (isp); -if (stream_restart) { -atomisp_css_input_set_mode (&isp->asd,IA_CSS_INPUT_MODE_BUFFERED_SENSOR ); +atomisp_css_input_set_mode (&isp->asd,IA_CSS_INPUT_MODE_BUFFERED_SENSOR ); - css_pipe_id =atomisp_get_css_pipe_id (&isp->asd); -if (atomisp_css_start (&isp->asd, css_pipe_id, true)) { -dev_warn (isp->dev, -"start SP failed, so do not set streaming to be enable!\n" ); - }else { -spin_lock_irqsave (&isp->lock, flags); - isp->asd.streaming = true; -spin_unlock_irqrestore (&isp->lock, flags); - } - -atomisp_csi2_configure (&isp->asd); + css_pipe_id =atomisp_get_css_pipe_id (&isp->asd); +if (atomisp_css_start (&isp->asd, css_pipe_id, true)) { +dev_warn (isp->dev,"start SP failed, so do not set streaming to be enable!\n" ); + }else { +spin_lock_irqsave (&isp->lock, flags); + isp->asd.streaming = true; +spin_unlock_irqrestore (&isp->lock, flags); } +atomisp_csi2_configure (&isp->asd); +atomisp_css_irq_enable (isp,IA_CSS_IRQ_INFO_CSS_RECEIVER_SOF ,atomisp_css_valid_sof (isp));if (atomisp_freq_scaling (isp,ATOMISP_DFS_MODE_AUTO , true) <0 )dev_dbg (isp->dev,"DFS auto failed while recovering!\n" ); -if (stream_restart) { -/* -* dequeueing buffers is not needed. CSS will recycle -* buffers that it has. -*/ -atomisp_flush_video_pipe (&isp->asd.video_out,VB2_BUF_STATE_ERROR , false); +/* Dequeueing buffers is not needed, CSS will recycle buffers that it has */ +atomisp_flush_video_pipe (&isp->asd.video_out,VB2_BUF_STATE_ERROR , false); -/* Requeue unprocessed per-frame parameters. */ -atomisp_recover_params_queue (&isp->asd.video_out); +/* Requeue unprocessed per-frame parameters. */ +atomisp_recover_params_queue (&isp->asd.video_out); - ret =v4l2_subdev_call ( - isp->inputs[isp->asd.input_curr].camera, video, - s_stream,1 ); -if (ret) -dev_warn (isp->dev, -"can't start streaming on sensor!\n" ); - } + ret =v4l2_subdev_call (isp->inputs[isp->asd.input_curr].camera, video, s_stream,1 ); +if (ret) +dev_err (isp->dev,"Starting sensor stream failed: %d\n" , ret); out_unlock:mutex_unlock (&isp->mutex);
Signature · 1 line
2.40.1
PATCH 24/30 media: atomisp: Rename atomisp_destroy_pipes_stream_force() to atomisp_destroy_pipes_stream()
In reply to Hans de GoedeThere now no longer is a non force version of atomisp_destroy_pipes_stream_force() so having the _force postfix no longer makes sense rename it to atomisp_destroy_pipes_stream().
--- drivers/staging/media/atomisp/pci/atomisp_compat.h | 2 +- .../staging/media/atomisp/pci/atomisp_compat_css20.c | 10 +++++----- drivers/staging/media/atomisp/pci/atomisp_fops.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_compat.h +1 -1
@@ -215,7 +215,7 @@ int atomisp_css_input_configure_port(struct atomisp_sub_device *asd, unsigned int metadata_height);int atomisp_create_pipes_stream (struct atomisp_sub_device *asd); -void atomisp_destroy_pipes_stream_force (struct atomisp_sub_device *asd); +void atomisp_destroy_pipes_stream (struct atomisp_sub_device *asd);void atomisp_css_stop (struct atomisp_sub_device *asd,enum ia_css_pipe_id pipe_id,bool in_reset);
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +5 -5
@@ -548,7 +548,7 @@ static int __destroy_pipes(struct atomisp_sub_device *asd)return 0 ; } -void atomisp_destroy_pipes_stream_force (struct atomisp_sub_device *asd) +void atomisp_destroy_pipes_stream (struct atomisp_sub_device *asd) {if (__destroy_streams (asd))dev_warn (asd->isp->dev,"destroy stream failed.\n" );
@@ -746,7 +746,7 @@ int atomisp_create_pipes_stream(struct atomisp_sub_device *asd)int atomisp_css_update_stream (struct atomisp_sub_device *asd) { -atomisp_destroy_pipes_stream_force (asd); +atomisp_destroy_pipes_stream (asd);return atomisp_create_pipes_stream (asd); }
@@ -1034,7 +1034,7 @@ int atomisp_css_start(struct atomisp_sub_device *asd,* destroying all pipes. */ if (sp_is_started) { -atomisp_destroy_pipes_stream_force (asd); +atomisp_destroy_pipes_stream (asd);ia_css_stop_sp ();atomisp_create_pipes_stream (asd); }
@@ -1824,7 +1824,7 @@ void atomisp_css_stop(struct atomisp_sub_device *asd,* CSS 2.0 API limitation: ia_css_stop_sp() can only be called after * destroying all pipes. */ -atomisp_destroy_pipes_stream_force (asd); +atomisp_destroy_pipes_stream (asd);atomisp_init_raw_buffer_bitmap (asd);
@@ -2314,7 +2314,7 @@ static int __get_frame_info(struct atomisp_sub_device *asd,return 0 ; get_info_err: -atomisp_destroy_pipes_stream_force (asd); +atomisp_destroy_pipes_stream (asd);return -EINVAL ; }
drivers/staging/media/atomisp/pci/atomisp_fops.c +1 -1
@@ -614,7 +614,7 @@ static int atomisp_release(struct file *file) isp->inputs[asd->input_curr].asd =NULL ; } -atomisp_destroy_pipes_stream_force (asd); +atomisp_destroy_pipes_stream (asd); ret =v4l2_subdev_call (isp->flash, core, s_power,0 );if (ret <0 && ret != -ENODEV && ret != -ENOIOCTLCMD )
Signature · 1 line
2.40.1
PATCH 25/30 media: atomisp: Allow system suspend to continue with open /dev/video# nodes
In reply to Hans de GoedeJust having a /dev/video# node open is not a reason to block system suspend. At least when userspace is not streaming.
In that case the worst case scenario is that streams have been created, but we can just destroy those before powering off the ISP and recreate the streams on resume.
Fixing suspend when streaming is left as a FIXME item for later.
--- .../media/atomisp/pci/atomisp_subdev.h | 1 + .../staging/media/atomisp/pci/atomisp_v4l2.c | 23 ++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_subdev.h +1 -0
@@ -301,6 +301,7 @@ struct atomisp_sub_device {*/ bool streaming;bool stream_prepared;/* whether css stream is created */ +bool recreate_streams_on_resume;unsigned int latest_preview_exp_id;/* CSS ZSL/SDV raw buffer id */
drivers/staging/media/atomisp/pci/atomisp_v4l2.c +15 -8
@@ -664,13 +664,7 @@ static int atomisp_suspend(struct device *dev)dev_get_drvdata (dev);unsigned long flags; -/* -* FIXME: Suspend is not supported by sensors. Abort if any video -* node was opened. -*/ -if (atomisp_dev_users (isp)) -return -EBUSY ; - +/* FIXME: Suspend is not supported by sensors. Abort if streaming. */ spin_lock_irqsave (&isp->lock, flags);if (isp->asd.streaming) {spin_unlock_irqrestore (&isp->lock, flags);
@@ -681,12 +675,25 @@ static int atomisp_suspend(struct device *dev)pm_runtime_resume (dev); + isp->asd.recreate_streams_on_resume = isp->asd.stream_prepared; +atomisp_destroy_pipes_stream (&isp->asd); +return atomisp_power_off (dev); }static int atomisp_resume (struct device *dev) { -return atomisp_power_on (dev); +struct atomisp_device *isp =dev_get_drvdata (dev); +int ret; + + ret =atomisp_power_on (dev); +if (ret) +return ret; + +if (isp->asd.recreate_streams_on_resume) + ret =atomisp_create_pipes_stream (&isp->asd); + +return ret; }int atomisp_csi_lane_config (struct atomisp_device *isp)
Signature · 1 line
2.40.1
PATCH 26/30 media: atomisp: Remove atomisp_[sub]dev_users()
In reply to Hans de GoedeThe atomisp_[sub]dev_users() functions are not used anymore, remove them.
--- drivers/staging/media/atomisp/pci/atomisp_fops.c | 10 ---------- drivers/staging/media/atomisp/pci/atomisp_fops.h | 3 --- 2 files changed, 13 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_fops.c +0 -10
@@ -489,16 +489,6 @@ static void atomisp_subdev_init_struct(struct atomisp_sub_device *asd)/* * file operation functions */ -static unsigned int atomisp_subdev_users (struct atomisp_sub_device *asd) -{ -return asd->video_out.users; -} - -unsigned int atomisp_dev_users (struct atomisp_device *isp) -{ -return atomisp_subdev_users (&isp->asd); -} -static int atomisp_open (struct file *file) {struct video_device *vdev =video_devdata (file);
drivers/staging/media/atomisp/pci/atomisp_fops.h +0 -3
@@ -22,9 +22,6 @@#define __ATOMISP_FOPS_H__#include "atomisp_subdev.h" -unsigned int atomisp_dev_users (struct atomisp_device *isp); -unsigned int atomisp_sub_dev_users (struct atomisp_sub_device *asd); -/* * Memory help functions for image frame and private parameters */
Signature · 1 line
2.40.1
PATCH 27/30 media: atomisp: Remove unused css_pipe_id argument from atomisp_css_[start|stop]()
In reply to Hans de GoedeThe css_pipe_id argument pass to atomisp_css_[start|stop]() is not used, drop it.
--- drivers/staging/media/atomisp/pci/atomisp_cmd.c | 7 ++----- drivers/staging/media/atomisp/pci/atomisp_compat.h | 6 ++---- drivers/staging/media/atomisp/pci/atomisp_compat_css20.c | 6 ++---- drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 9 ++------- 4 files changed, 8 insertions(+), 20 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_cmd.c +2 -5
@@ -932,7 +932,6 @@ void atomisp_assert_recovery_work(struct work_struct *work) struct atomisp_device *isp = container_of(work, struct atomisp_device, assert_recovery_work);struct pci_dev *pdev =to_pci_dev (isp->dev); -enum ia_css_pipe_id css_pipe_id;unsigned long flags;int ret;
@@ -954,8 +953,7 @@ void atomisp_assert_recovery_work(struct work_struct *work)atomisp_clear_css_buffer_counters (&isp->asd); - css_pipe_id =atomisp_get_css_pipe_id (&isp->asd); -atomisp_css_stop (&isp->asd, css_pipe_id, true); +atomisp_css_stop (&isp->asd, true); isp->asd.preview_exp_id =1 ; isp->asd.postview_exp_id =1 ;
@@ -976,8 +974,7 @@ void atomisp_assert_recovery_work(struct work_struct *work)atomisp_css_input_set_mode (&isp->asd,IA_CSS_INPUT_MODE_BUFFERED_SENSOR ); - css_pipe_id =atomisp_get_css_pipe_id (&isp->asd); -if (atomisp_css_start (&isp->asd, css_pipe_id, true)) { +if (atomisp_css_start (&isp->asd, true)) {dev_warn (isp->dev,"start SP failed, so do not set streaming to be enable!\n" ); }else {spin_lock_irqsave (&isp->lock, flags);
drivers/staging/media/atomisp/pci/atomisp_compat.h +2 -4
@@ -78,8 +78,7 @@ int atomisp_q_dis_buffer_to_css(struct atomisp_sub_device *asd,void ia_css_mmu_invalidate_cache (void ); -int atomisp_css_start (struct atomisp_sub_device *asd, -enum ia_css_pipe_id pipe_id,bool in_reset); +int atomisp_css_start (struct atomisp_sub_device *asd,bool in_reset);void atomisp_css_update_isp_params (struct atomisp_sub_device *asd); void atomisp_css_update_isp_params_on_pipe(struct atomisp_sub_device *asd,
@@ -217,8 +216,7 @@ int atomisp_css_input_configure_port(struct atomisp_sub_device *asd,int atomisp_create_pipes_stream (struct atomisp_sub_device *asd);void atomisp_destroy_pipes_stream (struct atomisp_sub_device *asd); -void atomisp_css_stop (struct atomisp_sub_device *asd, -enum ia_css_pipe_id pipe_id,bool in_reset); +void atomisp_css_stop (struct atomisp_sub_device *asd,bool in_reset); void atomisp_css_continuous_set_num_raw_frames( struct atomisp_sub_device *asd,
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +2 -4
@@ -985,8 +985,7 @@ int atomisp_q_dis_buffer_to_css(struct atomisp_sub_device *asd,return 0 ; } -int atomisp_css_start (struct atomisp_sub_device *asd, -enum ia_css_pipe_id pipe_id,bool in_reset) +int atomisp_css_start (struct atomisp_sub_device *asd,bool in_reset) {struct atomisp_device *isp = asd->isp;bool sp_is_started = false;
@@ -1814,8 +1813,7 @@ int atomisp_css_input_configure_port(return 0 ; } -void atomisp_css_stop (struct atomisp_sub_device *asd, -enum ia_css_pipe_id pipe_id,bool in_reset) +void atomisp_css_stop (struct atomisp_sub_device *asd,bool in_reset) {unsigned long irqflags;unsigned int i;
drivers/staging/media/atomisp/pci/atomisp_ioctl.c +2 -7
@@ -1120,7 +1120,6 @@ int atomisp_start_streaming(struct vb2_queue *vq, unsigned int count)struct atomisp_sub_device *asd = pipe->asd;struct atomisp_device *isp = asd->isp;struct pci_dev *pdev =to_pci_dev (isp->dev); -enum ia_css_pipe_id css_pipe_id;unsigned long irqflags;int ret;
@@ -1135,8 +1134,6 @@ int atomisp_start_streaming(struct vb2_queue *vq, unsigned int count)/* Input system HW workaround */ atomisp_dma_burst_len_cfg (asd); - css_pipe_id =atomisp_get_css_pipe_id (asd); -/* Invalidate caches. FIXME: should flush only necessary buffers */ wbinvd ();
@@ -1151,7 +1148,7 @@ int atomisp_start_streaming(struct vb2_queue *vq, unsigned int count) } asd->params.dvs_6axis =NULL ; - ret =atomisp_css_start (asd, css_pipe_id, false); + ret =atomisp_css_start (asd, false);if (ret) {atomisp_flush_video_pipe (pipe,VB2_BUF_STATE_QUEUED , true); goto out_unlock;
@@ -1217,7 +1214,6 @@ void atomisp_stop_streaming(struct vb2_queue *vq)struct atomisp_sub_device *asd = pipe->asd;struct atomisp_device *isp = asd->isp;struct pci_dev *pdev =to_pci_dev (isp->dev); -enum ia_css_pipe_id css_pipe_id;unsigned long flags;int ret;
@@ -1247,8 +1243,7 @@ void atomisp_stop_streaming(struct vb2_queue *vq)atomisp_clear_css_buffer_counters (asd);atomisp_css_irq_enable (isp,IA_CSS_IRQ_INFO_CSS_RECEIVER_SOF , false); - css_pipe_id =atomisp_get_css_pipe_id (asd); -atomisp_css_stop (asd, css_pipe_id, false); +atomisp_css_stop (asd, false);atomisp_flush_video_pipe (pipe,VB2_BUF_STATE_ERROR , true);
Signature · 1 line
2.40.1
PATCH 28/30 media: atomisp: Remove unused atomisp_get_css_pipe_id() function
In reply to Hans de GoedeRemove no longer user atomisp_get_css_pipe_id() function.
--- .../staging/media/atomisp/pci/atomisp_ioctl.c | 28 ------------------- .../staging/media/atomisp/pci/atomisp_ioctl.h | 3 -- 2 files changed, 31 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_ioctl.c +0 -28
@@ -1068,34 +1068,6 @@ static int atomisp_dqbuf_wrapper(struct file *file, void *fh, struct v4l2_bufferreturn 0 ; } -enum ia_css_pipe_id atomisp_get_css_pipe_id (struct atomisp_sub_device *asd) -{ -/* -* Disable vf_pp and run CSS in video mode. This allows using ISP -* scaling but it has one frame delay due to CSS internal buffering. -*/ -if (asd->vfpp->val ==ATOMISP_VFPP_DISABLE_SCALER ) -return IA_CSS_PIPE_ID_VIDEO ; - -/* -* Disable vf_pp and run CSS in still capture mode. In this mode -* CSS does not cause extra latency with buffering, but scaling -* is not available. -*/ -if (asd->vfpp->val ==ATOMISP_VFPP_DISABLE_LOWLAT ) -return IA_CSS_PIPE_ID_CAPTURE ; - -switch (asd->run_mode->val) { -case ATOMISP_RUN_MODE_PREVIEW : -return IA_CSS_PIPE_ID_PREVIEW ; -case ATOMISP_RUN_MODE_VIDEO : -return IA_CSS_PIPE_ID_VIDEO ; -case ATOMISP_RUN_MODE_STILL_CAPTURE : -default : -return IA_CSS_PIPE_ID_CAPTURE ; - } -} -/* Input system HW workaround */ /* Input system address translation corrupts burst during */ /* invalidate. SW workaround for this is to set burst length */
drivers/staging/media/atomisp/pci/atomisp_ioctl.h +0 -3
@@ -42,9 +42,6 @@ int atomisp_alloc_css_stat_bufs(struct atomisp_sub_device *asd,int atomisp_start_streaming (struct vb2_queue *vq,unsigned int count);void atomisp_stop_streaming (struct vb2_queue *vq); -enum ia_css_pipe_id atomisp_get_css_pipe_id (struct atomisp_sub_device - *asd); -extern const struct v4l2_ioctl_ops atomisp_ioctl_ops;/* compat_ioctl for 32bit userland app and 64bit kernel */
Signature · 1 line
2.40.1
PATCH 29/30 media: atomisp: Remove in_reset argument from atomisp_css_start()
In reply to Hans de GoedeThe in_reset argument to atomisp_css_start() is only ever true in atomisp_assert_recovery_work(), drop the argument and move the special reset handlig to atomisp_assert_recovery_work().
--- drivers/staging/media/atomisp/pci/atomisp_cmd.c | 8 +++++++- drivers/staging/media/atomisp/pci/atomisp_compat.h | 2 +- .../staging/media/atomisp/pci/atomisp_compat_css20.c | 11 +---------- drivers/staging/media/atomisp/pci/atomisp_ioctl.c | 2 +- 4 files changed, 10 insertions(+), 13 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_cmd.c +7 -1
@@ -974,7 +974,13 @@ void atomisp_assert_recovery_work(struct work_struct *work)atomisp_css_input_set_mode (&isp->asd,IA_CSS_INPUT_MODE_BUFFERED_SENSOR ); -if (atomisp_css_start (&isp->asd, true)) { +/* Recreate streams destroyed by atomisp_css_stop() */ +atomisp_create_pipes_stream (&isp->asd); + +/* Invalidate caches. FIXME: should flush only necessary buffers */ +wbinvd (); + +if (atomisp_css_start (&isp->asd)) {dev_warn (isp->dev,"start SP failed, so do not set streaming to be enable!\n" ); }else {spin_lock_irqsave (&isp->lock, flags);
drivers/staging/media/atomisp/pci/atomisp_compat.h +1 -1
@@ -78,7 +78,7 @@ int atomisp_q_dis_buffer_to_css(struct atomisp_sub_device *asd,void ia_css_mmu_invalidate_cache (void ); -int atomisp_css_start (struct atomisp_sub_device *asd,bool in_reset); +int atomisp_css_start (struct atomisp_sub_device *asd);void atomisp_css_update_isp_params (struct atomisp_sub_device *asd); void atomisp_css_update_isp_params_on_pipe(struct atomisp_sub_device *asd,
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +1 -10
@@ -985,21 +985,12 @@ int atomisp_q_dis_buffer_to_css(struct atomisp_sub_device *asd,return 0 ; } -int atomisp_css_start (struct atomisp_sub_device *asd,bool in_reset) +int atomisp_css_start (struct atomisp_sub_device *asd) {struct atomisp_device *isp = asd->isp;bool sp_is_started = false;int ret =0 , i =0 ; -if (in_reset) { - ret =atomisp_css_update_stream (asd); -if (ret) -return ret; - -/* Invalidate caches. FIXME: should flush only necessary buffers */ -wbinvd (); - } -if (!sh_css_hrt_system_is_idle ())dev_err (isp->dev,"CSS HW not idle before starting SP\n" );
drivers/staging/media/atomisp/pci/atomisp_ioctl.c +1 -1
@@ -1120,7 +1120,7 @@ int atomisp_start_streaming(struct vb2_queue *vq, unsigned int count) } asd->params.dvs_6axis =NULL ; - ret =atomisp_css_start (asd, false); + ret =atomisp_css_start (asd);if (ret) {atomisp_flush_video_pipe (pipe,VB2_BUF_STATE_QUEUED , true); goto out_unlock;
Signature · 1 line
2.40.1
PATCH 30/30 media: atomisp: Set asd.subdev.devnode once from isp_subdev_init_entities()
In reply to Hans de GoedeNow that we have only one /dev/video# node we can set asd.subdev.devnode once from isp_subdev_init_entities(), replacing the hack to set it the last opened/closed /dev/video# node from atomisp_open() / atomisp_release().
--- drivers/staging/media/atomisp/pci/atomisp_fops.c | 4 ---- drivers/staging/media/atomisp/pci/atomisp_subdev.c | 1 + 2 files changed, 1 insertion(+), 4 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_fops.c +0 -4
@@ -505,8 +505,6 @@ static int atomisp_open(struct file *file)mutex_lock (&isp->mutex); - asd->subdev.devnode = vdev; -if (!isp->input_cnt) {dev_err (isp->dev,"no camera attached\n" ); ret = -EINVAL ;
@@ -567,8 +565,6 @@ static int atomisp_release(struct file *file)dev_dbg (isp->dev,"release device %s\n" , vdev->name); - asd->subdev.devnode = vdev; -/* Note file must not be used after this! */ vb2_fop_release (file);
drivers/staging/media/atomisp/pci/atomisp_subdev.c +1 -0
@@ -881,6 +881,7 @@ 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 ;
Signature · 1 line
2.40.1
Quoted 7 lines · Hans de Goede
Hi All,
Here is an atomisp patch-series to continue the simplification / exotic feature removal of atomisp. Specifically this series makes atomisp register only 1 /dev/video# node.
Quoted 8 lines
The other patches are some preparation + follow-up work for this change, as well as a whole bunch of folow-up clean-ups.
The cleanups focus on removing the various count / users functions which atomisp used before when there were multiple nodes. This is preparation work for eventually allowing opening the same node multipe-times, as is normal for standard v4l2 /dev/video# nodes.
As usual
for non-commented and otherwise depending on your answers. I.o.w. feel free to add if you are going to address as I suggested.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Hi,
Quoted 17 lines · Andy Shevchenko
Quoted 7 lines · Hans de Goede
Hi All,
Here is an atomisp patch-series to continue the simplification / exotic feature removal of atomisp. Specifically this series makes atomisp register only 1 /dev/video# node.
Quoted 8 lines
The other patches are some preparation + follow-up work for this change, as well as a whole bunch of folow-up clean-ups.
The cleanups focus on removing the various count / users functions which atomisp used before when there were multiple nodes. This is preparation work for eventually allowing opening the same node multipe-times, as is normal for standard v4l2 /dev/video# nodes.
Quoted 4 lines
As usual
Reviewed-by Andy Shevchenko <[email protected]>for non-commented and otherwise depending on your answers. I.o.w. feel free to add if you are going to address as I suggested.
Thank you for all the reviews.
I've pushed a new version of the patches addressing all your comments and adding your Reviewed-by to:
https://git.kernel.org/pub/scm/linux/kernel/git/hansg/linux.git/log/?h=media-atomisp
Regards,
Hans