media: atomisp: change the detection of ISP2401 at runtime
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Mon, 1 Jun 2020 07:43:24 +0000 (09:43 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Thu, 11 Jun 2020 17:11:39 +0000 (19:11 +0200)
Instead of having a static var to detect it, let's use the
already-existing arch-specific bytes, as this is how other
parts of the code also checks when it needs to do something
different, depending on an specific chipset version.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
17 files changed:
drivers/staging/media/atomisp/include/linux/atomisp.h
drivers/staging/media/atomisp/include/linux/atomisp_platform.h
drivers/staging/media/atomisp/pci/atomisp_cmd.c
drivers/staging/media/atomisp/pci/atomisp_common.h
drivers/staging/media/atomisp/pci/atomisp_compat_css20.c
drivers/staging/media/atomisp/pci/atomisp_ioctl.c
drivers/staging/media/atomisp/pci/atomisp_subdev.c
drivers/staging/media/atomisp/pci/atomisp_v4l2.c
drivers/staging/media/atomisp/pci/camera/pipe/src/pipe_binarydesc.c
drivers/staging/media/atomisp/pci/runtime/binary/src/binary.c
drivers/staging/media/atomisp/pci/runtime/debug/src/ia_css_debug.c
drivers/staging/media/atomisp/pci/sh_css.c
drivers/staging/media/atomisp/pci/sh_css_firmware.c
drivers/staging/media/atomisp/pci/sh_css_mipi.c
drivers/staging/media/atomisp/pci/sh_css_params.c
drivers/staging/media/atomisp/pci/sh_css_sp.c
drivers/staging/media/atomisp/pci/sh_css_version.c

index 0913d8b25097f4b19d1218891bb8dbac6badedcb..22c4103b0385639432c5242260a02b3bf4d2510c 100644 (file)
@@ -70,9 +70,6 @@
 #define V4L2_MBUS_FMT_CUSTOM_M10MO_RAW 0x800b
 #endif
 
-/* FIXME: for now, let's use a boolean to identify the type of atomisp chipset */
-extern bool atomisp_hw_is_isp2401;
-
 /* Configuration used by Bayer noise reduction and YCC noise reduction */
 struct atomisp_nr_config {
        /* [gain] Strength of noise reduction for Bayer NR (Used by Bayer NR) */
index 395d7c022ad1d899c818df6b403d02daa71041a1..873344a02ccf670ef26d528fcc4a8234e255bc78 100644 (file)
@@ -19,6 +19,7 @@
 #define ATOMISP_PLATFORM_H_
 
 #include <asm/intel-family.h>
+#include <asm/processor.h>
 
 #include <linux/i2c.h>
 #include <linux/sfi.h>
@@ -240,11 +241,19 @@ const struct atomisp_camera_caps *atomisp_get_default_camera_caps(void);
 /* API from old platform_camera.h, new CPUID implementation */
 #define __IS_SOC(x) (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL && \
                     boot_cpu_data.x86 == 6 &&                       \
-                    boot_cpu_data.x86_model == x)
+                    boot_cpu_data.x86_model == (x))
+#define __IS_SOCS(x,y) (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL && \
+                       boot_cpu_data.x86 == 6 &&                       \
+                       (boot_cpu_data.x86_model == (x) || \
+                        boot_cpu_data.x86_model == (y)))
 
 #define IS_MFLD        __IS_SOC(INTEL_FAM6_ATOM_SALTWELL_MID)
 #define IS_BYT __IS_SOC(INTEL_FAM6_ATOM_SILVERMONT)
 #define IS_CHT __IS_SOC(INTEL_FAM6_ATOM_AIRMONT)
 #define IS_MOFD        __IS_SOC(INTEL_FAM6_ATOM_AIRMONT_MID)
 
+/* Both CHT and MOFD come with ISP2401 */
+#define IS_ISP2401 __IS_SOCS(INTEL_FAM6_ATOM_AIRMONT, \
+                            INTEL_FAM6_ATOM_AIRMONT_MID)
+
 #endif /* ATOMISP_PLATFORM_H_ */
index 8d0a437f507c722594506e72b7771dcc1e70090a..51df1463e395334cf990c07a03fd6c047a80740c 100644 (file)
@@ -989,7 +989,7 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, int error,
                break;
        case IA_CSS_BUFFER_TYPE_VF_OUTPUT_FRAME:
        case IA_CSS_BUFFER_TYPE_SEC_VF_OUTPUT_FRAME:
-               if (atomisp_hw_is_isp2401)
+               if (IS_ISP2401)
                        reset_wdt_timer = true;
 
                pipe->buffers_in_css--;
@@ -1038,18 +1038,18 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, int error,
 
                        asd->pending_capture_request--;
 
-                       if (atomisp_hw_is_isp2401)
+                       if (IS_ISP2401)
                                asd->re_trigger_capture = false;
 
                        dev_dbg(isp->dev, "Trigger capture again for new buffer. err=%d\n",
                                err);
-               } else if (atomisp_hw_is_isp2401) {
+               } else if (IS_ISP2401) {
                        asd->re_trigger_capture = true;
                }
                break;
        case IA_CSS_BUFFER_TYPE_OUTPUT_FRAME:
        case IA_CSS_BUFFER_TYPE_SEC_OUTPUT_FRAME:
-               if (atomisp_hw_is_isp2401)
+               if (IS_ISP2401)
                        reset_wdt_timer = true;
 
                pipe->buffers_in_css--;
@@ -1219,7 +1219,7 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, int error,
                 */
                wake_up(&vb->done);
        }
-       if (atomisp_hw_is_isp2401)
+       if (IS_ISP2401)
                atomic_set(&pipe->wdt_count, 0);
 
        /*
@@ -1239,7 +1239,7 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, int error,
        if (!error && q_buffers)
                atomisp_qbuffers_to_css(asd);
 
-       if (atomisp_hw_is_isp2401) {
+       if (IS_ISP2401) {
                /* If there are no buffers queued then
                * delete wdt timer. */
                if (asd->streaming != ATOMISP_DEVICE_STREAMING_ENABLED)
@@ -1475,7 +1475,7 @@ void atomisp_wdt_work(struct work_struct *work)
                return;
        }
 
-       if (!atomisp_hw_is_isp2401) {
+       if (!IS_ISP2401) {
                dev_err(isp->dev, "timeout %d of %d\n",
                        atomic_read(&isp->wdt_count) + 1,
                        ATOMISP_ISP_MAX_TIMEOUT_COUNT);
@@ -1598,11 +1598,11 @@ void atomisp_wdt_work(struct work_struct *work)
                                atomisp_flush_bufs_and_wakeup(asd);
                                complete(&asd->init_done);
                        }
-                       if (atomisp_hw_is_isp2401)
+                       if (IS_ISP2401)
                                atomisp_wdt_stop(asd, false);
                }
 
-               if (!atomisp_hw_is_isp2401) {
+               if (!IS_ISP2401) {
                        atomic_set(&isp->wdt_count, 0);
                } else {
                        isp->isp_fatal_error = true;
@@ -1614,7 +1614,7 @@ void atomisp_wdt_work(struct work_struct *work)
        }
 
        __atomisp_css_recover(isp, true);
-       if (atomisp_hw_is_isp2401) {
+       if (IS_ISP2401) {
                for (i = 0; i < isp->num_of_streams; i++) {
                        struct atomisp_sub_device *asd = &isp->asd[i];
 
@@ -1671,7 +1671,7 @@ void atomisp_wdt(struct timer_list *t)
        struct atomisp_sub_device *asd;
        struct atomisp_device *isp;
 
-       if (!atomisp_hw_is_isp2401) {
+       if (!IS_ISP2401) {
                asd = from_timer(asd, t, wdt);
                isp = asd->isp;
        } else {
@@ -1730,7 +1730,7 @@ void atomisp_wdt_refresh_pipe(struct atomisp_video_pipe *pipe,
 
 void atomisp_wdt_refresh(struct atomisp_sub_device *asd, unsigned int delay)
 {
-       if (!atomisp_hw_is_isp2401) {
+       if (!IS_ISP2401) {
                unsigned long next;
 
                if (delay != ATOMISP_WDT_KEEP_CURRENT_DELAY)
@@ -1793,7 +1793,7 @@ void atomisp_wdt_stop(struct atomisp_sub_device *asd, bool sync)
 {
        dev_dbg(asd->isp->dev, "WDT stop:\n");
 
-       if (!atomisp_hw_is_isp2401) {
+       if (!IS_ISP2401) {
                if (sync) {
                        del_timer_sync(&asd->wdt);
                        cancel_work_sync(&asd->isp->wdt_work);
@@ -3014,7 +3014,7 @@ int atomisp_calculate_real_zoom_region(struct atomisp_sub_device *asd,
         * map real crop region base on above calculating base max crop region.
         */
 
-       if (!atomisp_hw_is_isp2401) {
+       if (!IS_ISP2401) {
                dz_config->zoom_region.origin.x = dz_config->zoom_region.origin.x
                                                  * eff_res.width
                                                  / asd->sensor_array_res.width;
@@ -3584,7 +3584,7 @@ int atomisp_cp_lsc_table(struct atomisp_sub_device *asd,
        if (!from_user && css_param->update_flag.shading_table)
                return 0;
 
-       if (atomisp_hw_is_isp2401) {
+       if (IS_ISP2401) {
                if (copy_from_compatible(&dest_st, source_st,
                                        sizeof(struct atomisp_shading_table),
                                        from_user)) {
@@ -3617,7 +3617,7 @@ int atomisp_cp_lsc_table(struct atomisp_sub_device *asd,
        }
 
        /* Shading table size per color */
-       if (!atomisp_hw_is_isp2401) {
+       if (!IS_ISP2401) {
                if (st->width > ISP2400_SH_CSS_MAX_SCTBL_WIDTH_PER_COLOR ||
                    st->height > ISP2400_SH_CSS_MAX_SCTBL_HEIGHT_PER_COLOR) {
                        dev_err(asd->isp->dev, "shading table w/h validate failed!");
@@ -3700,7 +3700,7 @@ int atomisp_css_cp_dvs2_coefs(struct atomisp_sub_device *asd,
        if (!from_user && css_param->update_flag.dvs2_coefs)
                return 0;
 
-       if (!atomisp_hw_is_isp2401) {
+       if (!IS_ISP2401) {
                if (sizeof(*cur) != sizeof(coefs->grid) ||
                    memcmp(&coefs->grid, cur, sizeof(coefs->grid))) {
                        dev_err(asd->isp->dev, "dvs grid mis-match!\n");
@@ -3843,7 +3843,7 @@ int atomisp_cp_dvs_6axis_config(struct atomisp_sub_device *asd,
        old_6axis_config = css_param->dvs_6axis;
        dvs_6axis_config = old_6axis_config;
 
-       if (atomisp_hw_is_isp2401) {
+       if (IS_ISP2401) {
                struct ia_css_dvs_6axis_config t_6axis_config;
 
                if (copy_from_compatible(&t_6axis_config, source_6axis_config,
@@ -3978,7 +3978,7 @@ int atomisp_cp_morph_table(struct atomisp_sub_device *asd,
 
        old_morph_table = css_param->morph_table;
 
-       if (atomisp_hw_is_isp2401) {
+       if (IS_ISP2401) {
                struct ia_css_morph_table mtbl;
 
                if (copy_from_compatible(&mtbl, source_morph_table,
@@ -4168,7 +4168,7 @@ void atomisp_handle_parameter_and_buffer(struct atomisp_video_pipe *pipe)
 
        atomisp_qbuffers_to_css(asd);
 
-       if (!atomisp_hw_is_isp2401) {
+       if (!IS_ISP2401) {
                if (!atomisp_is_wdt_running(asd) && atomisp_buffers_queued(asd))
                        atomisp_wdt_start(asd);
        } else {
@@ -4204,7 +4204,7 @@ int atomisp_set_parameters(struct video_device *vdev,
                __func__, arg->per_frame_setting, asd->index,
                arg->isp_config_id, vdev->name);
 
-       if (atomisp_hw_is_isp2401) {
+       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__);
@@ -5070,7 +5070,7 @@ static int __enable_continuous_mode(struct atomisp_sub_device *asd,
                enable, asd->continuous_raw_buffer_size->val,
                !asd->continuous_viewfinder->val);
 
-       if (!atomisp_hw_is_isp2401)
+       if (!IS_ISP2401)
                atomisp_css_capture_set_mode(asd, IA_CSS_CAPTURE_MODE_PRIMARY);
        else
                atomisp_update_capture_mode(asd);
@@ -5961,7 +5961,7 @@ int atomisp_set_fmt(struct video_device *vdev, struct v4l2_format *f)
                 * which appears to be related by a hardware
                 * performance limitation.  It's unclear why this
                 * particular code triggers the issue. */
-               if (!atomisp_hw_is_isp2401 || crop_needs_override) {
+               if (!IS_ISP2401 || crop_needs_override) {
                        if (isp_sink_crop.width * main_compose.height >
                            isp_sink_crop.height * main_compose.width) {
                                sink_crop.height = isp_sink_crop.height;
@@ -6107,7 +6107,7 @@ int atomisp_set_shading_table(struct atomisp_sub_device *asd,
        }
 
        /* Shading table size per color */
-       if (!atomisp_hw_is_isp2401) {
+       if (!IS_ISP2401) {
                if (user_shading_table->width > ISP2400_SH_CSS_MAX_SCTBL_WIDTH_PER_COLOR ||
                    user_shading_table->height > ISP2400_SH_CSS_MAX_SCTBL_HEIGHT_PER_COLOR)
                        return -EINVAL;
index d47de6731d6a765331474743b97c68fd02aafb75..b29874f2bc0f57b4abda342432da3a0bb33ffe19 100644 (file)
@@ -44,10 +44,6 @@ extern int pad_h;
 /* ISP2401 */
 #define ATOMISP_CSS_ISP_PIPE_VERSION_2_7    1
 
-#define IS_ISP2401(isp)                                                        \
-       (((isp)->media_dev.hw_revision & ATOMISP_HW_REVISION_MASK)      \
-        >= (ATOMISP_HW_REVISION_ISP2401_LEGACY << ATOMISP_HW_REVISION_SHIFT))
-
 struct atomisp_format_bridge {
        unsigned int pixelformat;
        unsigned int depth;
index 70d21401383ec26195275b0ac614d6de1a66b705..8f2161f881b5d9336df1d3c77deda94772b878f5 100644 (file)
@@ -612,7 +612,7 @@ static void __apply_additional_pipe_config(
                    default_capture_config.mode == IA_CSS_CAPTURE_MODE_RAW)
                        stream_env->pipe_configs[pipe_id].enable_dz = false;
 
-               if (atomisp_hw_is_isp2401) {
+               if (IS_ISP2401) {
                        /* the isp default to use ISP2.2 and the camera hal will
                        * control whether use isp2.7 */
                        if (asd->select_isp_version->val == ATOMISP_CSS_ISP_PIPE_VERSION_2_7)
@@ -4159,7 +4159,7 @@ int atomisp_css_isr_thread(struct atomisp_device *isp,
                        for (i = 0; i < isp->num_of_streams; i++)
                                atomisp_wdt_stop(&isp->asd[i], 0);
 
-                       if (!atomisp_hw_is_isp2401)
+                       if (!IS_ISP2401)
                                atomisp_wdt(&isp->asd[0].wdt);
                        else
                                queue_work(isp->wdt_work_queue, &isp->wdt_work);
@@ -4193,7 +4193,7 @@ int atomisp_css_isr_thread(struct atomisp_device *isp,
                        atomisp_buf_done(asd, 0, IA_CSS_BUFFER_TYPE_OUTPUT_FRAME,
                                         current_event.pipe, true, stream_id);
 
-                       if (!atomisp_hw_is_isp2401)
+                       if (!IS_ISP2401)
                                reset_wdt_timer[asd->index] = true; /* ISP running */
 
                        break;
@@ -4203,7 +4203,7 @@ int atomisp_css_isr_thread(struct atomisp_device *isp,
                        atomisp_buf_done(asd, 0, IA_CSS_BUFFER_TYPE_SEC_OUTPUT_FRAME,
                                         current_event.pipe, true, stream_id);
 
-                       if (!atomisp_hw_is_isp2401)
+                       if (!IS_ISP2401)
                                reset_wdt_timer[asd->index] = true; /* ISP running */
 
                        break;
@@ -4227,7 +4227,7 @@ int atomisp_css_isr_thread(struct atomisp_device *isp,
                                         IA_CSS_BUFFER_TYPE_VF_OUTPUT_FRAME,
                                         current_event.pipe, true, stream_id);
 
-                       if (!atomisp_hw_is_isp2401)
+                       if (!IS_ISP2401)
                                reset_wdt_timer[asd->index] = true; /* ISP running */
 
                        break;
@@ -4236,7 +4236,7 @@ int atomisp_css_isr_thread(struct atomisp_device *isp,
                        atomisp_buf_done(asd, 0,
                                         IA_CSS_BUFFER_TYPE_SEC_VF_OUTPUT_FRAME,
                                         current_event.pipe, true, stream_id);
-                       if (!atomisp_hw_is_isp2401)
+                       if (!IS_ISP2401)
                                reset_wdt_timer[asd->index] = true; /* ISP running */
 
                        break;
@@ -4262,7 +4262,7 @@ int atomisp_css_isr_thread(struct atomisp_device *isp,
                }
        }
 
-       if (atomisp_hw_is_isp2401)
+       if (IS_ISP2401)
                return 0;
 
        /* ISP2400: If there are no buffers queued then delete wdt timer. */
index 4abb1462a44ddcd29c388b1a9418a4c15edd7616..0a76f388b38b9c47f6762e82f79598aae670f8be 100644 (file)
@@ -582,7 +582,7 @@ static int atomisp_enum_input(struct file *file, void *fh,
         * ioctl is the only way to enum inputs + possible external actuators
         * for 3A tuning purpose.
         */
-       if (!atomisp_hw_is_isp2401)
+       if (!IS_ISP2401)
                motor = isp->inputs[index].motor;
        else
                motor = isp->motor;
@@ -732,7 +732,7 @@ static int atomisp_s_input(struct file *file, void *fh, unsigned int input)
                goto error;
        }
 
-       if (!atomisp_hw_is_isp2401) {
+       if (!IS_ISP2401) {
                motor = isp->inputs[input].motor;
        } else {
                motor = isp->motor;
@@ -1264,7 +1264,7 @@ done:
                } else {
                        atomisp_qbuffers_to_css(asd);
 
-                       if (!atomisp_hw_is_isp2401) {
+                       if (!IS_ISP2401) {
                                if (!atomisp_is_wdt_running(asd) && atomisp_buffers_queued(asd))
                                        atomisp_wdt_start(asd);
                        } else {
@@ -1288,7 +1288,7 @@ done:
            pipe->capq.streaming &&
            !asd->enable_raw_buffer_lock->val &&
            asd->params.offline_parm.num_captures == 1) {
-               if (!atomisp_hw_is_isp2401) {
+               if (!IS_ISP2401) {
                        asd->pending_capture_request++;
                        dev_dbg(isp->dev, "Add one pending capture request.\n");
                } else {
@@ -1687,7 +1687,7 @@ static int atomisp_streamon(struct file *file, void *fh,
 
        /* Reset pending capture request count. */
        asd->pending_capture_request = 0;
-       if (atomisp_hw_is_isp2401)
+       if (IS_ISP2401)
                asd->re_trigger_capture = false;
 
        if ((atomisp_subdev_streaming_count(asd) > sensor_start_stream) &&
@@ -1828,7 +1828,7 @@ start_sensor:
                        dev_err(isp->dev, "master slave sensor stream on failed!\n");
                        goto out;
                }
-               if (!atomisp_hw_is_isp2401) {
+               if (!IS_ISP2401) {
                        __wdt_on_master_slave_sensor(isp, wdt_duration);
                } else {
                        __wdt_on_master_slave_sensor_pipe(pipe, wdt_duration, true);
@@ -1836,7 +1836,7 @@ start_sensor:
                goto start_delay_wq;
        } else if (asd->depth_mode->val && (atomisp_streaming_count(isp) <
                                            ATOMISP_DEPTH_SENSOR_STREAMON_COUNT)) {
-               if (atomisp_hw_is_isp2401)
+               if (IS_ISP2401)
                        __wdt_on_master_slave_sensor_pipe(pipe, wdt_duration, false);
                goto start_delay_wq;
        }
@@ -1858,7 +1858,7 @@ start_sensor:
                goto out;
        }
 
-       if (!atomisp_hw_is_isp2401) {
+       if (!IS_ISP2401) {
                if (atomisp_buffers_queued(asd))
                        atomisp_wdt_refresh(asd, wdt_duration);
        } else {
@@ -2317,7 +2317,7 @@ static int atomisp_queryctl(struct file *file, void *fh,
        case V4L2_CID_FOCUS_ABSOLUTE:
        case V4L2_CID_FOCUS_RELATIVE:
        case V4L2_CID_FOCUS_STATUS:
-               if (!atomisp_hw_is_isp2401) {
+               if (!IS_ISP2401) {
                        return v4l2_queryctrl(isp->inputs[asd->input_curr].camera->
                                            ctrl_handler, qc);
                }
@@ -2358,7 +2358,7 @@ static int atomisp_camera_g_ext_ctrls(struct file *file, void *fh,
        int i;
        int ret = 0;
 
-       if (!atomisp_hw_is_isp2401)
+       if (!IS_ISP2401)
                motor = isp->inputs[asd->input_curr].motor;
        else
                motor = isp->motor;
@@ -2467,7 +2467,7 @@ static int atomisp_camera_s_ext_ctrls(struct file *file, void *fh,
        int i;
        int ret = 0;
 
-       if (!atomisp_hw_is_isp2401)
+       if (!IS_ISP2401)
                motor = isp->inputs[asd->input_curr].motor;
        else
                motor = isp->motor;
@@ -2696,7 +2696,7 @@ static long atomisp_vidioc_default(struct file *file, void *fh,
        else
                asd = atomisp_to_video_pipe(vdev)->asd;
 
-       if (!atomisp_hw_is_isp2401)
+       if (!IS_ISP2401)
                motor = isp->inputs[asd->input_curr].motor;
        else
                motor = isp->motor;
@@ -2721,7 +2721,7 @@ static long atomisp_vidioc_default(struct file *file, void *fh,
        }
        switch (cmd) {
        case ATOMISP_IOC_S_SENSOR_RUNMODE:
-               if (atomisp_hw_is_isp2401)
+               if (IS_ISP2401)
                        err = atomisp_set_sensor_runmode(asd, arg);
                else
                        err = -EINVAL;
@@ -2896,7 +2896,7 @@ static long atomisp_vidioc_default(struct file *file, void *fh,
                                       core, ioctl, cmd, arg);
                break;
        case ATOMISP_IOC_G_UPDATE_EXPOSURE:
-               if (atomisp_hw_is_isp2401)
+               if (IS_ISP2401)
                        err = v4l2_subdev_call(isp->inputs[asd->input_curr].camera,
                                               core, ioctl, cmd, arg);
                else
index 7bc8083a2fb5ab9c5bca73d8a8ea498ab67829e7..6ba817f1565540dbfb016adb1a5fb00e77e7f450 100644 (file)
@@ -1222,7 +1222,7 @@ static int isp_subdev_init_entities(struct atomisp_sub_device *asd)
            v4l2_ctrl_new_custom(&asd->ctrl_handler,
                                 &ctrl_disable_dz,
                                 NULL);
-       if (atomisp_hw_is_isp2401) {
+       if (IS_ISP2401) {
                asd->select_isp_version = v4l2_ctrl_new_custom(&asd->ctrl_handler,
                                                               &ctrl_select_isp_version,
                                                               NULL);
index 03c0c5e91f6fb4eea47fa347d3d8b3342626de66..73bea6a7ebb6c6091f49a4afb19676a64faa89f1 100644 (file)
@@ -124,11 +124,6 @@ MODULE_PARM_DESC(pad_h, "extra data for ISP processing");
  * be to replace this to something stored inside atomisp allocated
  * structures.
  */
-bool atomisp_hw_is_isp2401;
-
-/* Types of atomisp hardware */
-#define HW_IS_ISP2400 0
-#define HW_IS_ISP2401 1
 
 struct device *atomisp_dev;
 
@@ -1459,21 +1454,17 @@ static bool is_valid_device(struct pci_dev *dev,
        switch (id->device & ATOMISP_PCI_DEVICE_SOC_MASK) {
        case ATOMISP_PCI_DEVICE_SOC_MRFLD:
                a0_max_id = ATOMISP_PCI_REV_MRFLD_A0_MAX;
-               atomisp_hw_is_isp2401 = false;
                name = "Merrifield";
                break;
        case ATOMISP_PCI_DEVICE_SOC_BYT:
                a0_max_id = ATOMISP_PCI_REV_BYT_A0_MAX;
-               atomisp_hw_is_isp2401 = false;
                name = "Baytrail";
                break;
        case ATOMISP_PCI_DEVICE_SOC_ANN:
                name = "Anniedale";
-               atomisp_hw_is_isp2401 = true;
                break;
        case ATOMISP_PCI_DEVICE_SOC_CHT:
                name = "Cherrytrail";
-               atomisp_hw_is_isp2401 = true;
                break;
        default:
                dev_err(&dev->dev, "%s: unknown device ID %x04:%x04\n",
@@ -1493,13 +1484,13 @@ static bool is_valid_device(struct pci_dev *dev,
         */
 
 #if defined(ISP2400)
-       if (atomisp_hw_is_isp2401) {
+       if (IS_ISP2401) {
                dev_err(&dev->dev, "Support for %s (ISP2401) was disabled at compile time\n",
                        name);
                return false;
        }
 #else
-       if (!atomisp_hw_is_isp2401) {
+       if (!IS_ISP2401) {
                dev_err(&dev->dev, "Support for %s (ISP2400) was disabled at compile time\n",
                        name);
                return false;
@@ -1508,7 +1499,7 @@ static bool is_valid_device(struct pci_dev *dev,
 
        dev_info(&dev->dev, "Detected %s version %d (ISP240%c) on %s\n",
                name, dev->revision,
-               atomisp_hw_is_isp2401 ? '1' : '0',
+               IS_ISP2401 ? '1' : '0',
                product);
 
        return true;
@@ -1530,7 +1521,7 @@ static int init_atomisp_wdts(struct atomisp_device *isp)
        for (i = 0; i < isp->num_of_streams; i++) {
                struct atomisp_sub_device *asd = &isp->asd[i];
 
-               if (!atomisp_hw_is_isp2401)
+               if (!IS_ISP2401)
                        timer_setup(&asd->wdt, atomisp_wdt, 0);
                else {
                        timer_setup(&asd->video_out_capture.wdt,
index 70ccd2a363302502be1e1379ada08917cfccb87e..f20c9b02fbe04c716809deb194a7829c979e5d9b 100644 (file)
@@ -608,7 +608,7 @@ void ia_css_pipe_get_primary_binarydesc(
                 * since it has better performance. */
                if (pipe_version == IA_CSS_PIPE_VERSION_2_6_1)
                        prim_descr->striped = false;
-               else if (!atomisp_hw_is_isp2401) {
+               else if (!IS_ISP2401) {
                        prim_descr->striped = prim_descr->continuous &&
                                              (!pipe->stream->stop_copy_preview || !pipe->stream->disable_cont_vf);
                } else {
@@ -849,7 +849,7 @@ void ia_css_pipe_get_ldc_binarydesc(
        assert(out_info);
        IA_CSS_ENTER_PRIVATE("");
 
-       if (!atomisp_hw_is_isp2401) {
+       if (!IS_ISP2401) {
                *in_info = *out_info;
        } else {
                if (pipe->out_yuv_ds_input_info.res.width)
index 4e0d067ceb3db87722311117f14ce6e1f15005b2..9813014c3fd3db7b769ffdcbd3a13946714837ab 100644 (file)
@@ -1342,7 +1342,7 @@ ia_css_binary_fill_info(const struct ia_css_binary_xinfo *xinfo,
 
        if (info->enable.sc)
        {
-               if (!atomisp_hw_is_isp2401) {
+               if (!IS_ISP2401) {
                        binary->sctbl_width_per_color = _ISP2400_SCTBL_WIDTH_PER_COLOR(sc_3a_dis_padded_width, s3a_log_deci);
                        binary->sctbl_aligned_width_per_color = ISP2400_SH_CSS_MAX_SCTBL_ALIGNED_WIDTH_PER_COLOR;
                        binary->sctbl_height = _ISP2400_SCTBL_HEIGHT(sc_3a_dis_height, s3a_log_deci);
@@ -1358,7 +1358,7 @@ ia_css_binary_fill_info(const struct ia_css_binary_xinfo *xinfo,
                binary->sctbl_width_per_color         = 0;
                binary->sctbl_aligned_width_per_color = 0;
                binary->sctbl_height                  = 0;
-               if (atomisp_hw_is_isp2401) {
+               if (IS_ISP2401) {
                        binary->sctbl_legacy_width_per_color  = 0;
                        binary->sctbl_legacy_height           = 0;
                }
index 543359d200af1c00b88ecd420dbf02d8e9471672..f64d8243400b71d90afcee58c81f63993a0da72d 100644 (file)
@@ -3087,7 +3087,7 @@ ia_css_debug_dump_pipe_config(
                                     "capt_pp_in_res");
        ia_css_debug_dump_resolution(&config->vf_pp_in_res, "vf_pp_in_res");
 
-       if (atomisp_hw_is_isp2401) {
+       if (IS_ISP2401) {
                ia_css_debug_dump_resolution(&config->output_system_in_res,
                                            "output_system_in_res");
        }
@@ -3315,7 +3315,7 @@ static void debug_dump_one_trace(enum TRACE_CORE_ID proc_id)
                return;
        }
 
-       if (!atomisp_hw_is_isp2401) {
+       if (!IS_ISP2401) {
                tmp = ia_css_device_load_uint32(start_addr);
                point_num = (tmp >> 16) & 0xFFFF;
 
@@ -3349,7 +3349,7 @@ static void debug_dump_one_trace(enum TRACE_CORE_ID proc_id)
                if ((limit == (-1)) && (trace_read_buf[i] == 0))
                        limit = i;
        }
-       if (atomisp_hw_is_isp2401) {
+       if (IS_ISP2401) {
                ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "Status:\n");
                for (i = 0; i < SH_CSS_MAX_SP_THREADS; i++)
                        ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE,
@@ -3382,7 +3382,7 @@ static void debug_dump_one_trace(enum TRACE_CORE_ID proc_id)
        for (i = 0; i < point_num; i++) {
                j = (limit + i) % point_num;
                if (trace_read_buf[j]) {
-                       if (!atomisp_hw_is_isp2401) {
+                       if (!IS_ISP2401) {
                                TRACE_DUMP_FORMAT dump_format = FIELD_FORMAT_UNPACK(trace_read_buf[j]);
                        } else {
                                tid_val = FIELD_TID_UNPACK(trace_read_buf[j]);
index a722b886b2f582e73e448bafd9004ab2038ffa96..bf8f147df5bb1d2c16db7bece9fec0e9f522e225 100644 (file)
@@ -584,7 +584,7 @@ sh_css_config_input_network(struct ia_css_stream *stream) {
                vblank_cycles = vblank_lines * (width + hblank_cycles);
                sh_css_sp_configure_sync_gen(width, height, hblank_cycles,
                                             vblank_cycles);
-               if (!atomisp_hw_is_isp2401) {
+               if (!IS_ISP2401) {
                        if (pipe->stream->config.mode == IA_CSS_INPUT_MODE_TPG) {
                                /* TODO: move define to proper file in tools */
                                ia_css_device_store_uint32(GP_ISEL_TPG_MODE, 0);
@@ -1471,7 +1471,7 @@ static void start_pipe(
 
        assert(me); /* all callers are in this file and call with non null argument */
 
-       if (!atomisp_hw_is_isp2401) {
+       if (!IS_ISP2401) {
                coord = &me->config.internal_frame_origin_bqs_on_sctbl;
                params = me->stream->isp_params_configs;
        }
@@ -2938,7 +2938,7 @@ load_preview_binaries(struct ia_css_pipe *pipe) {
        if (err)
                return err;
 
-       if (atomisp_hw_is_isp2401) {
+       if (IS_ISP2401) {
                /* The delay latency determines the number of invalid frames after
                * a stream is started. */
                pipe->num_invalid_frames = pipe->dvs_frame_delay;
@@ -3009,7 +3009,7 @@ load_preview_binaries(struct ia_css_pipe *pipe) {
         * where the driver chooses for memory based input frames. In these cases, a copy binary (which typical
         * copies sensor data to DDR) does not have much use.
         */
-       if (!atomisp_hw_is_isp2401)
+       if (!IS_ISP2401)
                need_isp_copy_binary = !online && !continuous;
        else
                need_isp_copy_binary = !online && !continuous && !(pipe->stream->config.mode == IA_CSS_INPUT_MODE_MEMORY);
@@ -4028,7 +4028,7 @@ preview_start(struct ia_css_pipe *pipe) {
                }
        }
 
-       if (atomisp_hw_is_isp2401) {
+       if (IS_ISP2401) {
                coord = &pipe->config.internal_frame_origin_bqs_on_sctbl;
                params = pipe->stream->isp_params_configs;
        }
@@ -5725,7 +5725,7 @@ static int load_video_binaries(struct ia_css_pipe *pipe)
 
                tnr_info = mycs->video_binary.out_frame_info[0];
 
-               if (atomisp_hw_is_isp2401) {
+               if (IS_ISP2401) {
                        /* Select resolution for TNR. If
                        * output_system_in_resolution(GDC_out_resolution) is
                        * being used, then select that as it will also be in resolution for
@@ -5846,7 +5846,7 @@ static int video_start(struct ia_css_pipe *pipe)
                }
        }
 
-       if (atomisp_hw_is_isp2401) {
+       if (IS_ISP2401) {
                coord = &pipe->config.internal_frame_origin_bqs_on_sctbl;
                params = pipe->stream->isp_params_configs;
        }
@@ -6004,7 +6004,7 @@ static bool need_capture_pp(
        assert(pipe);
        assert(pipe->mode == IA_CSS_PIPE_ID_CAPTURE);
 
-       if (atomisp_hw_is_isp2401) {
+       if (IS_ISP2401) {
                /* ldc and capture_pp are not supported in the same pipeline */
                if (need_capt_ldc(pipe) == true)
                        return false;
@@ -6212,7 +6212,7 @@ static int load_primary_binaries(
 
        /* TODO Do we disable ldc for skycam */
        need_ldc = need_capt_ldc(pipe);
-       if (atomisp_hw_is_isp2401 && need_ldc) {
+       if (IS_ISP2401 && need_ldc) {
                /* ldc and capt_pp are not supported in the same pipeline */
                struct ia_css_binary_descr capt_ldc_descr;
 
@@ -6235,7 +6235,7 @@ static int load_primary_binaries(
        if (need_pp) {
                struct ia_css_binary_descr capture_pp_descr;
 
-               if (!atomisp_hw_is_isp2401)
+               if (!IS_ISP2401)
                        capt_pp_in_info = need_ldc ? &capt_ldc_out_info : &prim_out_info;
                else
                        capt_pp_in_info = &prim_out_info;
@@ -9556,7 +9556,7 @@ ia_css_stream_create(const struct ia_css_stream_config *stream_config,
                            effective_res.height);
        }
 
-       if (atomisp_hw_is_isp2401) {
+       if (IS_ISP2401) {
                for (i = 0; i < num_pipes; i++) {
                        if (pipes[i]->config.mode != IA_CSS_PIPE_MODE_ACC &&
                            pipes[i]->config.mode != IA_CSS_PIPE_MODE_COPY) {
@@ -9610,7 +9610,7 @@ ia_css_stream_create(const struct ia_css_stream_config *stream_config,
                        curr_stream->cont_capt = true;
                        curr_stream->disable_cont_vf = curr_stream->config.disable_cont_viewfinder;
 
-                       if (!atomisp_hw_is_isp2401)
+                       if (!IS_ISP2401)
                                curr_stream->stop_copy_preview = my_css.stop_copy_preview;
                }
 
@@ -9670,7 +9670,7 @@ ia_css_stream_create(const struct ia_css_stream_config *stream_config,
                /* set current stream */
                curr_pipe->stream = curr_stream;
 
-               if (!atomisp_hw_is_isp2401) {
+               if (!IS_ISP2401) {
                        /* take over effective info */
 
                        effective_res = curr_pipe->config.input_effective_res;
@@ -9705,11 +9705,11 @@ ia_css_stream_create(const struct ia_css_stream_config *stream_config,
                                goto ERR;
                }
 
-               if (atomisp_hw_is_isp2401)
+               if (IS_ISP2401)
                        pipe_info->output_system_in_res_info = curr_pipe->config.output_system_in_res;
 
                if (!spcopyonly) {
-                       if (!atomisp_hw_is_isp2401)
+                       if (!IS_ISP2401)
                                err = sh_css_pipe_get_shading_info(curr_pipe,
                                                                    &pipe_info->shading_info, NULL);
                        else
@@ -9834,7 +9834,7 @@ ia_css_stream_destroy(struct ia_css_stream *stream) {
                        }
                }
                free_mpi = stream->config.mode == IA_CSS_INPUT_MODE_BUFFERED_SENSOR;
-               if (atomisp_hw_is_isp2401) {
+               if (IS_ISP2401) {
                        free_mpi |= stream->config.mode == IA_CSS_INPUT_MODE_TPG;
                        free_mpi |= stream->config.mode == IA_CSS_INPUT_MODE_PRBS;
                }
@@ -9932,7 +9932,7 @@ ia_css_stream_get_info(const struct ia_css_stream *stream,
     */
 int
 ia_css_stream_load(struct ia_css_stream *stream) {
-       if (!atomisp_hw_is_isp2401) {
+       if (!IS_ISP2401) {
                int i;
                int err;
 
@@ -10058,7 +10058,7 @@ ia_css_stream_stop(struct ia_css_stream *stream) {
        }
 #endif
 
-       if (!atomisp_hw_is_isp2401) {
+       if (!IS_ISP2401) {
                err = ia_css_pipeline_request_stop(&stream->last_pipe->pipeline);
        } else {
                err = sh_css_pipes_stop(stream);
@@ -10080,7 +10080,7 @@ ia_css_stream_has_stopped(struct ia_css_stream *stream) {
 
        assert(stream);
 
-       if (!atomisp_hw_is_isp2401) {
+       if (!IS_ISP2401) {
                stopped = ia_css_pipeline_has_stopped(&stream->last_pipe->pipeline);
        } else {
                stopped = sh_css_pipes_have_stopped(stream);
@@ -10426,7 +10426,7 @@ ia_css_stop_sp(void) {
        }
 
        /* For now, stop whole SP */
-       if (!atomisp_hw_is_isp2401) {
+       if (!IS_ISP2401) {
                sh_css_write_host2sp_command(host2sp_cmd_terminate);
        } else {
                if (!sh_css_write_host2sp_command(host2sp_cmd_terminate))
index fc463b858c688859afaf54fc6aedd3c254f7e9f3..e7f364db0ae072e41373874370307a93ec5b2da0 100644 (file)
@@ -189,7 +189,7 @@ sh_css_check_firmware_version(struct device *dev, const char *fw_data)
 
        const char *release_version;
 
-       if (!atomisp_hw_is_isp2401)
+       if (!IS_ISP2401)
                release_version = isp2400_release_version;
        else
                release_version = isp2401_release_version;
@@ -230,7 +230,7 @@ sh_css_load_firmware(struct device *dev, const char *fw_data,
        int ret;
        const char *release_version;
 
-       if (!atomisp_hw_is_isp2401)
+       if (!IS_ISP2401)
                release_version = isp2400_release_version;
        else
                release_version = isp2401_release_version;
index 6a73424acfa1a3ab0805db479e038290a7e48664..2ef5dbd62a6d303071743042924c7d702663dc3c 100644 (file)
@@ -391,7 +391,7 @@ calculate_mipi_buff_size(
 
 static bool buffers_needed(struct ia_css_pipe *pipe)
 {
-       if (!atomisp_hw_is_isp2401) {
+       if (!IS_ISP2401) {
                if (pipe->stream->config.mode == IA_CSS_INPUT_MODE_BUFFERED_SENSOR)
                        return false;
                else
@@ -445,7 +445,7 @@ allocate_mipi_frames(struct ia_css_pipe *pipe,
                return 0; /* AM TODO: Check  */
        }
 
-       if (!atomisp_hw_is_isp2401)
+       if (!IS_ISP2401)
                port = (unsigned int)pipe->stream->config.source.port.port;
        else
                err = ia_css_mipi_is_source_port_valid(pipe, &port);
@@ -594,7 +594,7 @@ free_mipi_frames(struct ia_css_pipe *pipe) {
                        return err;
                }
 
-               if (!atomisp_hw_is_isp2401)
+               if (!IS_ISP2401)
                        port = (unsigned int)pipe->stream->config.source.port.port;
                else
                        err = ia_css_mipi_is_source_port_valid(pipe, &port);
@@ -710,7 +710,7 @@ send_mipi_frames(struct ia_css_pipe *pipe) {
                /* TODO: AM: maybe this should be returning an error. */
        }
 
-       if (!atomisp_hw_is_isp2401)
+       if (!IS_ISP2401)
                port = (unsigned int)pipe->stream->config.source.port.port;
        else
                err = ia_css_mipi_is_source_port_valid(pipe, &port);
index 1a799f659198b1b046279acbc90042297fd17592..ba42be9b06ebe59295cb1b53c9c8eb1bb4880a29 100644 (file)
@@ -2161,7 +2161,7 @@ ia_css_set_param_exceptions(const struct ia_css_pipe *pipe,
        params->dp_config.b  = params->wb_config.b;
        params->dp_config.gb = params->wb_config.gb;
 
-       if (atomisp_hw_is_isp2401) {
+       if (IS_ISP2401) {
                assert(pipe);
                assert(pipe->mode < IA_CSS_PIPE_ID_NUM);
 
@@ -2630,7 +2630,7 @@ sh_css_init_isp_params_from_config(struct ia_css_pipe *pipe,
         * before (NORM+OBC) or after. The folllowing code to set the
         * DPC configuration should be updated when this interface is made
         * available */
-       if (atomisp_hw_is_isp2401) {
+       if (IS_ISP2401) {
                sh_css_set_dp_config(pipe, params, config->dp_config);
                ia_css_set_param_exceptions(pipe, params);
        }
@@ -2651,7 +2651,7 @@ sh_css_init_isp_params_from_config(struct ia_css_pipe *pipe,
                goto exit;
        }
 
-       if (!atomisp_hw_is_isp2401)
+       if (!IS_ISP2401)
                ia_css_set_param_exceptions(pipe, params);
 
 exit:
@@ -3069,7 +3069,7 @@ sh_css_init_isp_params_from_global(struct ia_css_stream *stream,
                ia_css_set_ob_config(params, &default_ob_config);
                ia_css_set_dp_config(params, &default_dp_config);
 
-               if (!atomisp_hw_is_isp2401) {
+               if (!IS_ISP2401) {
                        ia_css_set_param_exceptions(pipe_in, params);
                } else {
                        for (i = 0; i < stream->num_pipes; i++) {
@@ -3196,7 +3196,7 @@ sh_css_init_isp_params_from_global(struct ia_css_stream *stream,
                                retval = false;
                                goto exit;
                        }
-                       if (atomisp_hw_is_isp2401) {
+                       if (IS_ISP2401) {
                                if (stream->pipes[i]->mode < IA_CSS_PIPE_ID_NUM) {
                                        sh_css_set_dp_config(stream->pipes[i], params,
                                                            &stream_params->pipe_dp_config[stream->pipes[i]->mode]);
@@ -3208,7 +3208,7 @@ sh_css_init_isp_params_from_global(struct ia_css_stream *stream,
                        }
                }
 
-               if (!atomisp_hw_is_isp2401)
+               if (!IS_ISP2401)
                        ia_css_set_param_exceptions(pipe_in, params);
 
                params->fpn_config.data = stream_params->fpn_config.data;
@@ -3362,7 +3362,7 @@ int ia_css_pipe_set_bci_scaler_lut(struct ia_css_pipe *pipe,
        pipe->scaler_pp_lut = mmgr_NULL;
 
        if (!stream_started) {
-               if (!atomisp_hw_is_isp2401)
+               if (!IS_ISP2401)
                        pipe->scaler_pp_lut = hmm_alloc(sizeof(zoom_table), HMM_BO_PRIVATE, 0, NULL, 0);
                else
                        pipe->scaler_pp_lut = sh_css_params_alloc_gdc_lut();
@@ -3407,7 +3407,7 @@ int sh_css_params_map_and_store_default_gdc_lut(void)
 
        host_lut_store((void *)zoom_table);
 
-       if (!atomisp_hw_is_isp2401)
+       if (!IS_ISP2401)
                default_gdc_lut = hmm_alloc(sizeof(zoom_table), HMM_BO_PRIVATE, 0, NULL, 0);
        else
                default_gdc_lut = sh_css_params_alloc_gdc_lut();
@@ -4020,7 +4020,7 @@ sh_css_params_write_to_ddr_internal(
                u32 enable_conv;
                size_t bytes;
 
-               if (!atomisp_hw_is_isp2401)
+               if (!IS_ISP2401)
                        bytes = ISP2400_SCTBL_BYTES(binary);
                else
                        bytes = ISP2401_SCTBL_BYTES(binary);
@@ -4117,7 +4117,7 @@ sh_css_params_write_to_ddr_internal(
        /* DPC configuration is made pipe specific to allow flexibility in positioning of the
         * DPC kernel. The code below sets the pipe specific configuration to
         * individual binaries. */
-       if (atomisp_hw_is_isp2401 &&
+       if (IS_ISP2401 &&
            params->pipe_dpc_config_changed[pipe_id] && binary->info->sp.enable.dpc)
        {
                unsigned int size   =
@@ -4220,7 +4220,7 @@ sh_css_params_write_to_ddr_internal(
                        if (!params->pipe_dvs_6axis_config[pipe_id]) {
                                struct ia_css_resolution dvs_offset = {0};
 
-                               if (!atomisp_hw_is_isp2401) {
+                               if (!IS_ISP2401) {
                                        dvs_offset.width = (PIX_SHIFT_FILTER_RUN_IN_X + binary->dvs_envelope.width) / 2;
                                } else {
                                        if (binary->dvs_envelope.width || binary->dvs_envelope.height) {
index 70c64cc4e2edd4bae42a9f8828853d7f0c8dc5a6..756aad4a6e43879b0afe9e9342742ca93154150d 100644 (file)
@@ -1343,7 +1343,7 @@ sh_css_sp_init_pipeline(struct ia_css_pipeline *me,
        }
 #endif
 
-       if (atomisp_hw_is_isp2401) {
+       if (IS_ISP2401) {
                /* For the shading correction type 1 (the legacy shading table conversion in css is not used),
                * the parameters are passed to the isp for the shading table centering.
                */
index c9d5c02c457137cdb6803dd94f5973834197311b..3ef690d6f2cfc0b974a011f92a8ff8ed1570398f 100644 (file)
@@ -14,6 +14,7 @@
  */
 
 #include "../../include/linux/atomisp.h"
+#include "../../include/linux/atomisp_platform.h"
 #include "ia_css_version.h"
 #include "ia_css_version_data.h"
 #include "ia_css_err.h"
@@ -23,7 +24,7 @@ int
 ia_css_get_version(char *version, int max_size) {
        char *css_version;
 
-       if (!atomisp_hw_is_isp2401)
+       if (!IS_ISP2401)
                css_version = ISP2400_CSS_VERSION_STRING;
        else
                css_version = ISP2401_CSS_VERSION_STRING;