media: atomisp: Turn asd->streaming state tracker into a bool
[platform/kernel/linux-starfive.git] / drivers / staging / media / atomisp / pci / atomisp_compat_css20.c
index d5b9c0f..cecdf11 100644 (file)
@@ -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;
 }
@@ -1328,8 +1302,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;
@@ -1612,29 +1585,6 @@ int atomisp_css_set_default_isys_config(struct atomisp_sub_device *asd,
        return 0;
 }
 
-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)
-{
-       struct ia_css_stream_config *s_config =
-                   &asd->stream_env[stream_id].stream_config;
-
-       s_config->isys_config[IA_CSS_STREAM_ISYS_STREAM_1].input_res.width =
-           s_config->isys_config[IA_CSS_STREAM_ISYS_STREAM_0].input_res.width;
-
-       s_config->isys_config[IA_CSS_STREAM_ISYS_STREAM_1].input_res.height =
-           s_config->isys_config[IA_CSS_STREAM_ISYS_STREAM_0].input_res.height / 2;
-
-       s_config->isys_config[IA_CSS_STREAM_ISYS_STREAM_1].linked_isys_stream_id
-           = IA_CSS_STREAM_ISYS_STREAM_0;
-       s_config->isys_config[IA_CSS_STREAM_ISYS_STREAM_0].format =
-           ATOMISP_INPUT_FORMAT_USER_DEF1;
-       s_config->isys_config[IA_CSS_STREAM_ISYS_STREAM_1].format =
-           ATOMISP_INPUT_FORMAT_USER_DEF2;
-       s_config->isys_config[IA_CSS_STREAM_ISYS_STREAM_1].valid = true;
-       return 0;
-}
-
 void atomisp_css_isys_two_stream_cfg_update_stream1(
     struct atomisp_sub_device *asd,
     enum atomisp_input_stream_id stream_id,
@@ -1820,49 +1770,6 @@ void atomisp_css_preview_enable_online(struct atomisp_sub_device *asd,
        }
 }
 
-void atomisp_css_video_enable_online(struct atomisp_sub_device *asd,
-                                    bool enable)
-{
-       struct atomisp_stream_env *stream_env =
-                   &asd->stream_env[ATOMISP_INPUT_STREAM_VIDEO];
-       int i;
-
-       if (stream_env->stream_config.online != enable) {
-               stream_env->stream_config.online = enable;
-               for (i = 0; i < IA_CSS_PIPE_ID_NUM; i++)
-                       stream_env->update_pipe[i] = true;
-       }
-}
-
-void atomisp_css_enable_continuous(struct atomisp_sub_device *asd,
-                                  bool enable)
-{
-       struct atomisp_stream_env *stream_env =
-                   &asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL];
-       int i;
-
-       if (stream_env->stream_config.continuous != !!enable) {
-               stream_env->stream_config.continuous = !!enable;
-               stream_env->stream_config.pack_raw_pixels = true;
-               for (i = 0; i < IA_CSS_PIPE_ID_NUM; i++)
-                       stream_env->update_pipe[i] = true;
-       }
-}
-
-void atomisp_css_enable_cvf(struct atomisp_sub_device *asd,
-                           bool enable)
-{
-       struct atomisp_stream_env *stream_env =
-                   &asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL];
-       int i;
-
-       if (stream_env->stream_config.disable_cont_viewfinder != !enable) {
-               stream_env->stream_config.disable_cont_viewfinder = !enable;
-               for (i = 0; i < IA_CSS_PIPE_ID_NUM; i++)
-                       stream_env->update_pipe[i] = true;
-       }
-}
-
 int atomisp_css_input_configure_port(
     struct atomisp_sub_device *asd,
     enum mipi_port_id port,
@@ -1910,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;
@@ -2432,7 +2337,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;
@@ -2469,39 +2373,6 @@ int atomisp_css_copy_configure_output(struct atomisp_sub_device *asd,
        return 0;
 }
 
-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)
-{
-       asd->stream_env[stream_index].pipe_configs[IA_CSS_PIPE_ID_YUVPP].
-       default_capture_config.mode =
-           IA_CSS_CAPTURE_MODE_RAW;
-
-       __configure_output(asd, stream_index, width, height, padded_width,
-                          format, IA_CSS_PIPE_ID_YUVPP);
-       return 0;
-}
-
-int atomisp_css_yuvpp_get_output_frame_info(
-    struct atomisp_sub_device *asd,
-    unsigned int stream_index,
-    struct ia_css_frame_info *info)
-{
-       return __get_frame_info(asd, stream_index, info,
-                               ATOMISP_CSS_OUTPUT_FRAME, IA_CSS_PIPE_ID_YUVPP);
-}
-
-int atomisp_css_yuvpp_get_viewfinder_frame_info(
-    struct atomisp_sub_device *asd,
-    unsigned int stream_index,
-    struct ia_css_frame_info *info)
-{
-       return __get_frame_info(asd, stream_index, info,
-                               ATOMISP_CSS_VF_FRAME, IA_CSS_PIPE_ID_YUVPP);
-}
-
 int atomisp_css_preview_configure_output(struct atomisp_sub_device *asd,
        unsigned int width, unsigned int height,
        unsigned int min_width,
@@ -3210,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)
@@ -3339,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++) {